AM PM Time Using SimpleDateFormat In Java
Chapter:
Date and Time
Last Updated:
28-04-2016 19:00:05 UTC
Program:
/* ............... START ............... */
import java.text.SimpleDateFormat;
import java.util.Date;
public class JavaAMPMFormatExample {
public static void main(String[] args) {
Date date = new Date();
// formatting time
String dateFormat = "HH:mm:ss a";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormat);
System.out.println("Time with AM/PM field : " + simpleDateFormat.format(date));
}
}
/* ............... END ............... */
Output
Time with AM/PM field : 20:28:31 PM
Tags
AM PM Time Using SimpleDateFormat, Java, Date And Time