用Java中的冒号偏移量解析ISO-8601 DateTime [英] Parsing ISO-8601 DateTime with offset with colon in Java
本文介绍了用Java中的冒号偏移量解析ISO-8601 DateTime的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在解析 Java 中的日期时间时遇到了麻烦,我的日期时间格式很奇怪.如何在java中解析2013-04-03T17:04:39.9430000+03:00
日期时间以在java中格式化dd.MM.yyyy HH:mm
?>
I have a trouble with parsing date time in java, I have a strange date time format.
How can I parse 2013-04-03T17:04:39.9430000+03:00
date time in java to format dd.MM.yyyy HH:mm
in java?
推荐答案
有问题的奇怪"格式是 ISO-8601 - 它的使用非常广泛.您可以使用 SimpleDateFormat 以大多数方式重新格式化它:
The "strange" format in question is ISO-8601 - its very widely used. You can use SimpleDateFormat to reformat it in most way you please:
SimpleDateFormat inFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
DateTime dtIn = inFormat.parse(dateString}); //where dateString is a date in ISO-8601 format
SimpleDateFormat outFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm");
String dtOut = outFormat.format(dtIn);
//parse it into a DateTime object if you need to interact with it as such
会给你你提到的格式.
这篇关于用Java中的冒号偏移量解析ISO-8601 DateTime的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文