Example usage for java.text SimpleDateFormat format

List of usage examples for java.text SimpleDateFormat format

Introduction

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

Prototype

public final String format(Date date) 

Source Link

Document

Formats a Date into a date-time string.

Usage

From source file:Main.java

public static void main(String[] args) throws Exception {
    SimpleDateFormat formatter = new SimpleDateFormat();

    String date = formatter.format(new Date());
    System.out.println("date = " + date);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    SimpleDateFormat formatter = new SimpleDateFormat();

    String date = formatter.format(new Date());
    System.out.println(formatter.getDateFormatSymbols().getLocalPatternChars());
    System.out.println("date = " + date);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    SimpleDateFormat formatter = new SimpleDateFormat();

    String date = formatter.format(new Date());
    System.out.println(formatter.toLocalizedPattern());
    System.out.println("date = " + date);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    SimpleDateFormat formatter = new SimpleDateFormat();

    String date = formatter.format(new Date());
    System.out.println(formatter.hashCode());
    System.out.println("date = " + date);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    SimpleDateFormat formatter = new SimpleDateFormat();

    String date = formatter.format(new Date());
    System.out.println(formatter.get2DigitYearStart());
    System.out.println("date = " + date);
}

From source file:Main.java

public static void main(String[] args) throws ParseException {

    SimpleDateFormat in = new SimpleDateFormat("MM/dd");
    SimpleDateFormat out = new SimpleDateFormat("MMMM, dd");

    System.out.println(out.format(in.parse("07/08")));

}

From source file:SDF.java

public static final void main(String[] args) {
    SimpleDateFormat localDateFormat = new SimpleDateFormat("HH:mm:ss");
    String time = localDateFormat.format(new Date());
    System.out.println(time);//from  w w w . ja  v  a 2 s  .c  om
}

From source file:Main.java

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));
}

From source file:Main.java

public static void main(String[] args) {
    Date date = new Date();
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yy");

    String strDate = sdf.format(date);
    System.out.println("formatted date in mm/dd/yy : " + strDate);

    sdf = new SimpleDateFormat("MM-dd-yyyy hh:mm:ss");
    strDate = sdf.format(date);//from w ww.  j ava2s  .  com
    System.out.println("formatted date in mm-dd-yyyy hh:mm:ss : " + strDate);
}

From source file:array05.java

public static void main(String[] args) {
    SimpleDateFormat sf = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z");
    System.out.println(sf.format(new Date()));
}