Java Date Time - Java Calendar.getTime()








Syntax

Calendar.getTime() has the following syntax.

public final Date getTime()

Example

In the following code shows how to use Calendar.getTime() method.

//from   ww w  .ja  v a  2 s  .  co  m


import java.util.Calendar;

public class Main {

   public static void main(String[] args) throws InterruptedException {

      Calendar cal = Calendar.getInstance();

      // print current time
      System.out.println(" Current time is : " + cal.getTime());


   }
}

The code above generates the following result.