[英]How to get a java date format to an XML?
I want to generate an XML file for the data inside the Java file. 我想为Java文件中的数据生成一个XML文件。 There is an date filed and I want to retrieve it as a Date to the XML file.
有一个归档的日期,我想将其作为XML文件的一个日期检索。 I have used createTextNode but it expects a string.
我使用过createTextNode,但是需要一个字符串。
Here is my code 这是我的代码
Element doctor=doc.createElement("doctor");
doctor.appendChild(doc.createTextNode(prescriptionData.getDoctor().getName()));
prescription.appendChild(doctor);
Element patient=doc.createElement("patient");
patient.appendChild(doc.createTextNode(prescriptionData.getPatient().getPatientName()));
prescription.appendChild(patient);
Element date=doc.createElement("date");
date.appendChild(doc.createTextNode(prescriptionData.getPrescribedDate()));
做prescriptionData.getPrescribedDate().toString()
尝试查找JAXBContext和Marshaller来创建XML文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.