Answers for "localdatetime to milliseconds"

0

java convert LocalDateTime to long

public long createTimestamp() {
        ZoneId zoneId = ZoneId.systemDefault();
        return LocalDateTime.now().atZone(zoneId).toEpochSecond();
    }
Posted by: Guest on July-24-2020
0

java localdatetime get milliseconds

#Date and time as String to Long (millis):

String dateTimeString = "2021-09-12T16:55:18.000Z";

DateTimeFormatter formatter = DateTimeFormatter
                .ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.ENGLISH);

LocalDateTime localDateTime = LocalDateTime
        .parse(dateTimeString, formatter);

Long dateTimeMillis = localDateTime
        .atZone(ZoneId.systemDefault())
        .toInstant()
        .toEpochMilli();
Posted by: Guest on June-27-2021
0

You can then use the number of milliseconds to convert it to a date object:

var msec = Date.parse("March 21, 2012");

var d = new Date(msec);

document.getElementById("demo").innerHTML = d;
Posted by: Guest on May-04-2021

Code answers related to "localdatetime to milliseconds"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language