Answers for "java current datetime in milliseconds"

3

java get current milliseconds

package com.tutorialspoint;

import java.lang.*;

public class SystemDemo {

   public static void main(String[] args) {

      // returns the current time in milliseconds
      System.out.print("Current Time in milliseconds = ");
      System.out.println(System.currentTimeMillis());
   }
}
Posted by: Guest on June-20-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

Code answers related to "java current datetime in milliseconds"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language