我昨天创造了这个精彩的静态方法,它工作得很好 - 昨天
但是,今天它给了我这个错误.我想这是从Z之前的太多0.
任何人都可以推荐如何以简洁的方式(Java 8)解析这种类型的String格式日期 - 请记住它昨天ISO_INSTANT也有效,所以也是一种有效的格式String?
Caused by: java.time.DateTimeException: Unable to obtain LocalDate from TemporalAccessor: {NanoOfSecond=0, InstantSeconds=1443451604, MilliOfSecond=0, MicroOfSecond=0},ISO of type java.time.format.Parsed
at java.time.LocalDate.from(LocalDate.java:368)
at java.time.LocalDateTime.from(LocalDateTime.java:456)
... 9 more
Run Code Online (Sandbox Code Playgroud)
在输入时间抛出异常:"2015-09-28T14:46:44.000000Z"
/**
*
* @param time the time in RFC3339 format (e.g. "2013-07-03T14:30:38Z" )
* @return
*/
public static LocalDateTime parseTimeINSTANT(String time) {
DateTimeFormatter f = DateTimeFormatter.ISO_INSTANT;
return LocalDateTime.from(f.parse(time));
}
Run Code Online (Sandbox Code Playgroud)
I have a string from a json response:
start: "2013-09-18T20:40:00+0000",
end: "2013-09-18T21:39:00+0000",
Run Code Online (Sandbox Code Playgroud)
How do i convert this string to a java DateTime Object?
i have tried using the following:
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
start = sdf.parse("2013-09-18T20:40:00+0000");
Run Code Online (Sandbox Code Playgroud)
but with this i can only create a Date Object. But the time binded in the String is kinda essential.
Any Help is greatly appreciated!
在下面的剪辑中,属性$F是类java.time.LocalDateTime或java.time.LocalDate.
<textField pattern="EE. dd.MM.yyyy">
<reportElement...>
</reportElement>
<textFieldExpression><![CDATA[$F{theLocalDateTime}]]></textFieldExpression>
</textField>
Run Code Online (Sandbox Code Playgroud)
如何pattern在jasper报告中使用textField格式化此属性 ?
我有这样的往返数据模式的timedate字符串:2012-07-05T11:30:44.1533815Z。这来自一些 .NET 服务。
如何将其转换为longJava 中的 a ?
我试过SimpleDateTimeFormat似乎我无法弄清楚正确的格式说明符..
我有一个字符串日期,并使用以下语句将其转换:
LocalDateTime datetime = LocalDateTime.parse(rs.getString("DateIn"), DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss"));
Run Code Online (Sandbox Code Playgroud)
现在我想转换datetime成Date用于比较的目的,如何转换呢?
joda.time.DateTime.now().toDate()
为什么不java.time.提供这样的方法?什么是转换的最佳方式java.time.LocalDateTime来java.util.date?
我知道我可以做如下,但感觉不对.
java.time.LocalDateTime date;
java.util.Date.from(date.atZone(ZoneId.systemDefault()).toInstant());
Run Code Online (Sandbox Code Playgroud)
我问,因为a java.util.Date仍然在很多系统中使用,比如通过hibernate进行postgres的数据库映射.