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:Test.java
public static void main(String args[]) { try {/*w w w . j a v a 2s . c om*/ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-DD"); System.out.println(sdf.parse(args[0]).toString()); } catch (Exception e) { e.printStackTrace(); } }
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())); }
From source file:Main.java
public static void main(String[] args) throws Exception { SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy"); // Prints a value in 2014 System.out.println(format.parse("16-16-2013")); format.setLenient(false);/*from w w w . ja v a 2 s. c o m*/ // Throws an exception System.out.println(format.parse("16-16-2013")); }
From source file:Main.java
public static void main(String args[]) { SimpleDateFormat df = new SimpleDateFormat("dd/MM/yy"); java.util.Date date = new Date(); df.applyPattern("EEE"); String day = df.format(date); if (day.compareTo("Sat") == 0 || day.compareTo("Sun") == 0) { System.out.println(day + ": Weekend"); } else {// w w w.ja v a 2 s . c om System.out.println(day + ": Weekday"); } }
From source file:Main.java
public static void main(String[] args) { SimpleDateFormat sdfDate = new SimpleDateFormat("dd/MM/yyyy"); Date now = new Date(); String strDate = sdfDate.format(now); System.out.println("Date: " + strDate); }
From source file:Main.java
public static void main(String[] args) { SimpleDateFormat sdfTime = new SimpleDateFormat("HH:mm:ss"); Date now = new Date(); String strTime = sdfTime.format(now); System.out.println("Time: " + strTime); }
From source file:Main.java
public static void main(String... args) { SimpleDateFormat df = new SimpleDateFormat("MM/dd/YYYY"); Calendar c = Calendar.getInstance(); System.out.println(df.format(c.getTime())); c.add(Calendar.YEAR, 60);/*from w ww . j a v a 2 s . c om*/ System.out.println(df.format(c.getTime())); }
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 www . j av a2s . c o m*/ }
From source file:Main.java
public static void main(String args[]) throws Exception { SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd"); String input = "2020-11-11"; System.out.print(input + " Parses as "); Date t = ft.parse(input);/*from w w w. ja v a2 s.co m*/ System.out.println(t); }
From source file:Main.java
public static void main(String[] args) throws Exception { SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy"); Date date = sdf.parse("31/12/06"); System.out.println(date);/*from www. j av a 2s. c o m*/ }