Example usage for java.text SimpleDateFormat SimpleDateFormat

List of usage examples for java.text SimpleDateFormat SimpleDateFormat

Introduction

In this page you can find the example usage for java.text SimpleDateFormat SimpleDateFormat.

Prototype

public SimpleDateFormat(String pattern) 

Source Link

Document

Constructs a SimpleDateFormat using the given pattern and the default date format symbols for the default java.util.Locale.Category#FORMAT FORMAT locale.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Format formatter = new SimpleDateFormat("EEEE, dd MMMM yyyy, hh:mm:ss.SSS a");
    String today = formatter.format(new Date());
    System.out.println("Today : " + today);
}

From source file:Main.java

public static void main(String[] argv) throws Exception {

    Format formatter = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss Z");
    Date date = (Date) formatter.parseObject("Tue, 29 Jan 2004 21:14:02 -0500");
}

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) {
    Date date = new Date();

    SimpleDateFormat sdf = new SimpleDateFormat("s");
    System.out.println("seconds in s 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();

    SimpleDateFormat sdf = new SimpleDateFormat("ss");
    System.out.println("seconds in ss format : " + sdf.format(date));
}

From source file:Main.java

public static void main(String[] args) {
    Date date = new Date();

    SimpleDateFormat sdf = new SimpleDateFormat("m");
    System.out.println("minutes in m format : " + sdf.format(date));

}

From source file:Main.java

public static void main(String[] args) {
    Date date = new Date();

    SimpleDateFormat sdf = new SimpleDateFormat("mm");
    System.out.println("minutes in mm format : " + sdf.format(date));

}

From source file:Main.java

public static void main(String[] args) {
    Date date = new Date();

    SimpleDateFormat sdf = new SimpleDateFormat("yy");
    System.out.println("Current year in yy format : " + sdf.format(date));
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Format formatter = new SimpleDateFormat("EEE, dd/MM/yyyy");
    String today = formatter.format(new Date());
    System.out.println("Today : " + today);

}