List of usage examples for java.text SimpleDateFormat format
public final String format(Date date)
From source file:Main.java
public static void main(String[] argv) throws Exception { Date date = new Date(); SimpleDateFormat simpDate; simpDate = new SimpleDateFormat("hh:mm:ss a"); System.out.println(simpDate.format(date)); }
From source file:Main.java
public static void main(String[] args) { Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("MMM"); System.out.println("Current Month in MMM format : " + sdf.format(date)); }
From source file:Main.java
public static void main(String[] args) { String strDateFormat = "dd"; SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat); System.out.println("Current day in dd format : " + sdf.format(new Date())); }
From source file:Main.java
public static void main(String[] args) { Date date = new Date(); String strDateFormat = "d"; SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat); System.out.println("Current day in d format : " + sdf.format(date)); }
From source file:Main.java
public static void main(String[] args) { Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy"); System.out.println("Current year in yyyy format : " + sdf.format(date)); }
From source file:Main.java
public static void main(String[] args) { Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("MMMM"); System.out.println("Current Month in MMMM format : " + sdf.format(date)); }
From source file:Main.java
public static void main(String[] argv) throws Exception { SimpleDateFormat formatter = new SimpleDateFormat(); formatter.applyLocalizedPattern("MMM"); String s = formatter.format(new Date()); System.out.println(s);/*w w w .ja va 2 s .co m*/ }
From source file:Main.java
public static void main(String[] args) { Timestamp timestamp = new Timestamp(System.currentTimeMillis()); Date date = new Date(timestamp.getTime()); // S is the millisecond SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM/dd/yyyy' 'HH:mm:ss:S"); System.out.println(simpleDateFormat.format(timestamp)); System.out.println(simpleDateFormat.format(date)); }
From source file:Main.java
public static void main(String[] args) { SimpleDateFormat sdfTime = new SimpleDateFormat("HH:mm:ss"); Date now = new Date(); String strTime = sdfTime.format(now); System.out.println("Time: " + strTime); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Date date = new Date(); SimpleDateFormat simpDate; simpDate = new SimpleDateFormat("dd MMM yyyy hh:mm:ss a"); System.out.println(simpDate.format(date)); }