Java Calendar convert to Date

Description

Java Calendar convert to Date


import java.util.Calendar;
import java.util.Date;
 
public class Main {
 
  public static void main(String[] args) {
    //use getInstance() method to get object of java Calendar class
    Calendar cal = Calendar.getInstance();
    Date date = cal.getTime();/*from www  .j a va  2 s.c o m*/
    //use getTime() method of Calendar class to get date and time
    System.out.println("Today is : " + date);  
  }
}



PreviousNext

Related