- (, ), ISO 8601, .
Date. Java-API , java.time, . , , , Instant ( ).
:
Instant i = Instant.now();
String s = i.toString();
Instant theSameInstant = Instant.parse(s);
toString ISO 8601 (, 2018-01-11T10:59:45.036Z), parse . , - , , , , .
, , Date.toString(), Sedalbs java.time:
DateTimeFormatter dtf
= DateTimeFormatter.ofPattern("EEE MMM dd HH:mm:ss zzz yyyy", Locale.ROOT);
Date d = new Date();
String s = d.toString();
Instant nearlyTheSameInstant = ZonedDateTime.parse(s, dtf).toInstant();
. JVMs, , . , , , - .
jambjos answer - : , Date.toString(), , , , , , - JVM.
Finally, it Date.toString()does not display the milliseconds that matter Date, which leads to inaccuracies of up to 999 milliseconds. If we use the string from Date.toString(), we can do nothing with it (which is why I named the variable nearlyTheSameInstant).
source
share