List of usage examples for java.text ParseException printStackTrace
public void printStackTrace()
From source file:Main.java
public static void main(String[] args) { try {/*from w w w .j a va 2 s . c o m*/ Date newDate = postedformat.parse("Wed, 30 Jun 2010 15:07:06 CST"); System.out.println("Date: " + newDate); } catch (ParseException e) { e.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { try {/*from www . j a v a 2 s . c o m*/ String target = "Thu Sep 28 20:29:30 JST 2015"; DateFormat df = new SimpleDateFormat("EEE MMM dd kk:mm:ss zzz yyyy"); Date result = df.parse(target); System.out.println(result); } catch (ParseException pe) { pe.printStackTrace(); } }
From source file:Main.java
public static void main(final String[] args) { final String date = "2015-10-02T12:23:23"; final String pattern = "yyyy-MM-dd'T'hh:mm:ss"; final SimpleDateFormat sdf = new SimpleDateFormat(pattern); try {/*from w ww .j a v a 2 s. c om*/ Date d = sdf.parse(date); System.out.println(d); } catch (ParseException e) { e.printStackTrace(); } }
From source file:MainClass.java
public static void main(String[] args) { String pattern = "MM/dd/yyyy"; SimpleDateFormat format = new SimpleDateFormat(pattern); try {//from www . j a v a2 s . c o m Date date = format.parse("12/31/2006"); System.out.println(date); } catch (ParseException e) { e.printStackTrace(); } // formatting System.out.println(format.format(new Date())); }
From source file:Main.java
public static void main(String[] args) { String str = "Thu Jun 06 2013 00:00:00 GMT+0530"; DateFormat outputDate = new SimpleDateFormat("EEE MMM dd yyyy hh:mm:ss"); try {// www .j av a 2s .c om Date date = outputDate.parse(str); String date1 = new SimpleDateFormat("dd-mm-yyyy, hh:mm:ss").format(date); System.out.println(date1.toString()); } catch (ParseException e) { e.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { String str_date = "2015-05-15 05:55:55.0"; DateFormat formatter;//from ww w. j a v a 2s . com Date date; try { formatter = new SimpleDateFormat("yyyy-MM-d HH:mm:ss"); date = formatter.parse(str_date); System.out.println(date); } catch (ParseException e) { e.printStackTrace(); } }
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 w w w . j av a2 s . c o m*/ 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
License:asdf
public static void main(String[] args) { String[] tests = { "01/23/1983", "1/23/1983", "asdf/3/2" }; String formatString = "MM/dd/yyyy"; SimpleDateFormat sdf = new SimpleDateFormat(formatString); for (String test : tests) { Date date = null;//from www .j av a2s . com try { date = sdf.parse(test); } catch (ParseException e) { e.printStackTrace(); } System.out.println(date); } }
From source file:Main.java
public static void main(String[] argv) { java.util.Date date;//from w ww. ja v a 2 s .co m SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); // Lenient try { date = sdf.parse("40/02/2015"); System.out.println("Lenient date is : " + date); } catch (ParseException e) { e.printStackTrace(); } // Rigorous sdf.setLenient(false); try { date = sdf.parse("40/02/2015"); System.out.println("Rigorous date (won't be printed!): " + date); } catch (ParseException e) { e.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { try {//from ww w. j ava 2s. c o m SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date date1 = sdf.parse("2015-12-31"); Date date2 = sdf.parse("2015-01-31"); System.out.println(sdf.format(date1)); System.out.println(sdf.format(date2)); if (date1.compareTo(date2) > 0) { System.out.println("Date1 is after Date2"); } else if (date1.compareTo(date2) < 0) { System.out.println("Date1 is before Date2"); } else if (date1.compareTo(date2) == 0) { System.out.println("Date1 is equal to Date2"); } else { System.out.println("How to get here?"); } } catch (ParseException ex) { ex.printStackTrace(); } }