Java – how to create a new localdatetime with zero time zone?
•
Java
new LocalDateTime(“1999-12-31T00:00:00Z”);
When I try to create this date, I get:
Exception in thread "main" java.lang.IllegalArgumentException: Invalid format: "1999-12-31T00:00:00Z" is malformed at "Z" at org.joda.time.format.DateTimeParserBucket.doParseMillis(DateTimeParserBucket.java:187) at org.joda.time.format.DateTimeFormatter.parseMillis(DateTimeFormatter.java:780) at org.joda.time.convert.StringConverter.getPartialValues(StringConverter.java:87) at org.joda.time.LocalDateTime.<init>(LocalDateTime.java:414) at org.joda.time.LocalDateTime.<init>(LocalDateTime.java:358)
How can I resolve this date to localdatetime?
Solution
You can't – localdatetime means that there is no relevant time zone at all If you have a timestamp anchored to the time zone (UTC in this case), you should use datetime instead of localdatetime
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码