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() 

Source Link

Document

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

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(formatter.get2DigitYearStart());
    System.out.println("date = " + date);
}

From source file:MainClass.java

public static void main(String args[]) throws Exception {
    SimpleDateFormat sdf = new SimpleDateFormat();
    DateFormatSymbols dfs = sdf.getDateFormatSymbols();

    String era[] = { "BCE", "CE" };
    dfs.setEras(era);/*from www. j  a v a  2 s . c  om*/
    sdf.setDateFormatSymbols(dfs);

    sdf.applyPattern("MMMM d yyyy G");
    System.out.println(sdf.format(new Date()));
}

From source file:Main.java

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

    SimpleDateFormat formatter = new SimpleDateFormat();

    StringBuffer sb = new StringBuffer();
    formatter.format(new Date(), sb, new FieldPosition(DateFormat.DATE_FIELD));
    System.out.println(sb);//from  w w  w . j  a va2  s .c om
}

From source file:Main.java

public static String date_string(long time) {
    SimpleDateFormat sdf = new SimpleDateFormat();
    sdf.applyPattern("yyyy-MM-dd HH:mm:ss");
    return sdf.format(new Date(time));
}