java localdatetime get milliseconds

Solutions on MaxInterview for java localdatetime get milliseconds by the best coders in the world

showing results for - "java localdatetime get milliseconds"
Coline
26 Nov 2018
1#Date and time as String to Long (millis):
2
3String dateTimeString = "2021-09-12T16:55:18.000Z";
4
5DateTimeFormatter formatter = DateTimeFormatter
6                .ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.ENGLISH);
7
8LocalDateTime localDateTime = LocalDateTime
9        .parse(dateTimeString, formatter);
10
11Long dateTimeMillis = localDateTime
12        .atZone(ZoneId.systemDefault())
13        .toInstant()
14        .toEpochMilli();