Showing posts with label java time print program. Show all posts
Showing posts with label java time print program. Show all posts

Sunday, 5 October 2014

JAVA Program to Dispay Current Time in AM PM Method

Time Display USING JAVA

A program to show the current time using SimpleDateFormat Method.


//A small java program to print the time on the screen
import java.util.Date;
import java.text.SimpleDateFormat;

public class DateFormat {
   
    public static void main(String[] args) {

            Date date = new Date();
            String strDateFormat = "HH:mm:ss a";
            SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat);
            System.out.println(sdf.format(date));
    }
    
}

Output:


00:15:13 AM