List of usage examples for java.text SimpleDateFormat SimpleDateFormat
public SimpleDateFormat(String pattern)
SimpleDateFormat
using the given pattern and the default date format symbols for the default java.util.Locale.Category#FORMAT FORMAT locale. From source file:Main.java
public static void main(String[] args) { String strDateFormat = "EEEE"; SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat); System.out.println("Current day of week in EEEE format : " + sdf.format(new 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);/*w w w . j av a 2 s. c om*/ System.out.println("formatted date in mm-dd-yyyy hh:mm:ss : " + strDate); }
From source file:Main.java
public static void main(String args[]) { String DATE_FORMAT = "yyyyMMdd"; SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT); Calendar c1 = Calendar.getInstance(); // today System.out.println("Today is " + sdf.format(c1.getTime())); }
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("dd/MM/yyyy"); strDate = sdf.format(date);/* ww w .j ava 2s . co m*/ System.out.println("formatted date in dd/MM/yyyy : " + strDate); }
From source file:Main.java
public static void main(String[] argv) throws Exception { DateFormat formatter = new SimpleDateFormat("hh.mm.ss a"); Date date = (Date) formatter.parse("02.47.44 PM"); System.out.println(date);//from ww w . j av a2s . c o m }
From source file:Main.java
public static void main(String[] argv) throws Exception { SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss Z"); Date date = (Date) formatter.parseObject("22:14:02 -0500"); System.out.println(date);/* w w w. ja v a2 s . c o m*/ }
From source file:Main.java
public static void main(String[] args) { DateFormat df = new SimpleDateFormat("MM/dd/yyyy"); Date today = Calendar.getInstance().getTime(); String reportDate = df.format(today); System.out.println("Report Date: " + reportDate); }
From source file:Main.java
public static void main(String[] args) { String maxDate = "15012009"; SimpleDateFormat fromFormat = new SimpleDateFormat("ddMMyyyy"); SimpleDateFormat toFormat = new SimpleDateFormat("MMMM dd, yyyy"); Date date = null;//from www.jav a2s .c om try { date = fromFormat.parse(maxDate); } catch (java.text.ParseException e) { e.printStackTrace(); } System.out.println("formated date:-" + toFormat.format(date)); }
From source file:Main.java
public static void main(String[] args) throws Exception { SimpleDateFormat broken = new SimpleDateFormat("kk:mm:ss"); broken.setTimeZone(TimeZone.getTimeZone("Etc/UTC")); SimpleDateFormat working = new SimpleDateFormat("HH:mm:ss"); working.setTimeZone(TimeZone.getTimeZone("Etc/UTC")); Date epoch = new Date(0); System.out.println(broken.format(epoch)); System.out.println(working.format(epoch)); }
From source file:DateTest.java
public static void main(String[] args) throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat("yyyy, MM, dd"); Date date = sdf.parse("2009, 12, 9"); System.out.println(date);//from w w w .j av a 2 s. c om }