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("H");
    String s = formatter.format(new Date());
    System.out.println(s);/*w  w  w .  j  av a 2s  .  com*/
}

From source file:Main.java

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

    Format formatter = new SimpleDateFormat("HH:mm:ss Z");
    Date date = (Date) formatter.parseObject("22:14:02 -0500");
    System.out.println(date);// w ww .  j ava 2s.  c  o  m
}

From source file:Main.java

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

    Format formatter = new SimpleDateFormat("EEEE");
    String s = formatter.format(new Date());
    System.out.println(s);//from   w  ww.j ava2s . c  o m
}

From source file:Main.java

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

    Format formatter = new SimpleDateFormat("E");
    String s = formatter.format(new Date());
    System.out.println(s);/*from   w w w  . j  a  va  2 s  .  c om*/
}

From source file:Main.java

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

    Format formatter = new SimpleDateFormat("yyyy");
    String s = formatter.format(new Date());
    System.out.println(s);/*from  w  w  w . ja v  a  2 s  .  co  m*/
}

From source file:Main.java

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

    Format formatter = new SimpleDateFormat("m");
    String s = formatter.format(new Date());
    System.out.println(s);//from www . j a va 2s  . c o m
}

From source file:Main.java

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

    Format formatter = new SimpleDateFormat("M");
    String s = formatter.format(new Date());
    System.out.println(s);//from w  w w .java 2s.co  m
}

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[] argv) throws Exception {

    Format formatter = new SimpleDateFormat("dd-MMM-yy");
    String s = formatter.format(new Date());
    System.out.println(s);/* w  ww . ja  v a  2  s. c  o m*/
}

From source file:Main.java

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

    Format formatter = new SimpleDateFormat("mm");
    String s = formatter.format(new Date());
    System.out.println(s);/*from   w  ww  .  j  av a2 s.  c  o m*/
}