Java Date get current date milliseconds value

Description

Java Date get current date milliseconds value

import java.util.Date;

public class Main {
  public static void main(String[] args) {
    // Create a new Date object
    Date currentDate = new Date();
    System.out.println("Current date: " + currentDate);

    // Get the milliseconds value of the current date
    long millis = currentDate.getTime();
    System.out.println("Current datetime in millis: " + millis);
  }//ww w .ja  v  a2s  .c  o  m
}



PreviousNext

Related