Showing posts with label print current time. Show all posts
Showing posts with label print current time. Show all posts

Tuesday, 25 July 2017

to print Current DATE and TIME


import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;

public class Time {
   public static void main(String[] args) {
     
       DateFormat df = new SimpleDateFormat("dd/MM/yy HH:mm:ss");
       Date dateobj = new Date();
       System.out.println(df.format(dateobj));

     
       Calendar calobj = Calendar.getInstance();
       System.out.println(df.format(calobj.getTime()));
    }
}

OUTPUT:
25/07/17 12:01:29

25/07/17 12:01:29