Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java 8 Parse ISO-8601 date ignoring presence (or absence) of timezone

Tags:

My application should be able to parse date ignoring timezone (I always know for sure that it is UTC). The problem is that the date might come in both following forms -

2017-09-11T12:44:07.793Z

0001-01-01T00:00:00

I can parse the first one using LocalDateTime, and the second one using Instant class. Is there a way to do that using a single mechanism?

P.S. I'm trying to avoid hardcoding Z at the end of the input string