programming-examples/java/Servlets_Session_Swing_Util/Use a SimpleDateFormat to print the date our way.java
2019-11-15 12:59:38 +01:00

19 lines
576 B
Java

Use a SimpleDateFormat to print the date our way
public class DateDemo {
public static void main(String[] args) {
//+
Date dNow = new Date();
/* Simple, Java 1.0 date printing */
System.out.println("It is now " + dNow.toString());
// Use a SimpleDateFormat to print the date our way.
SimpleDateFormat formatter
= new SimpleDateFormat ("E yyyy.MM.dd 'at' hh:mm:ss a zzz");
System.out.println("It is " + formatter.format(dNow));
//-
}
}