开发者

How to convert date time found in EXIF meta to XSD standard?

I'm parsing some EXIF files.

One of the meta fields is Date/Time Original in the format:

2009:09:02 03:28:43.

My application is creating some meta-object types that wil开发者_运维技巧l be validated against a schema. My schema defines the Date/Time Original field as being of type DateTime.

How can I convert the above to the XSD DateTime using Java?


Use a SimpleDateFormat instance to parse the date you get from the file to a java.util.Date object, then you can use another SimpleDateFormat to convert to the XSD date format. It should look like this:

SimpleDateFormat dateParser = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");
SimpleDateFormat dateConverter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
Date d = dateParser.parse(myExifDateString);
String xsdDateString = dateConverter.format(d);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜