List of usage examples for java.text ParseException printStackTrace
public void printStackTrace()
From source file:Main.java
public static Date dateXMLStringToDateControlador(SimpleDateFormat formatter, String sDate) { Date date = null;/*w w w . ja va 2s . co m*/ try { date = formatter.parse(sDate); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } return date; }
From source file:Main.java
@SuppressWarnings("deprecation") public static int getDay(String date) { try {/*from www . j a v a 2s .co m*/ return simpleDateFormat.parse(date).getDate(); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } return 0; }
From source file:Main.java
public static Date toDate(String template) { Date date = null;/*from w w w. ja v a 2s. co m*/ try { SimpleDateFormat inFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); date = inFormat.parse(template); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } return date; }
From source file:Main.java
public static float getTimeDiff(String start, String end) { java.text.DateFormat df = new java.text.SimpleDateFormat("HH:mm:ss"); java.util.Date date1 = null, date2 = null; try {//from w ww . j a v a 2 s . com date1 = df.parse(start); date2 = df.parse(end); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } return (float) ((date2.getTime() - date1.getTime())); }
From source file:Main.java
public static long ISOtoEpoch(String time) { try {/*from w w w. jav a2 s . c om*/ Date d = ISO8601DATEFORMAT.parse(time); return d.getTime(); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); return -2; } }
From source file:Main.java
public static Date parseNodeAsDate(Node node) { if (node == null) return null; String text = parseNodeAsText(node); Date date = null;/* www. ja v a 2 s . c o m*/ try { date = FULL_DATE.parse(text); } catch (ParseException e) { try { date = FULL_DATE2.parse(text); } catch (ParseException e2) { e2.printStackTrace(); } } return date; }
From source file:Main.java
/** * Convert String to java.util.Date/*from w w w .j av a 2 s.c om*/ */ public static Date dateFromString(String dateString) { Date convertedDate = null; try { SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy"); convertedDate = formatter.parse(dateString); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } return convertedDate; }
From source file:Main.java
public static Date convertToDate(String dateStr) { Date date = null;//from www. ja v a2 s . c o m try { date = formatter.parse(dateStr); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } return date; }
From source file:Main.java
@SuppressWarnings("deprecation") public static int getMonth(String date) { try {/*from ww w . j ava 2 s. c o m*/ return simpleDateFormat.parse(date).getMonth() + 1; } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } return 1; }
From source file:Main.java
public static Date getNowTimeDate() { Date date = new Date(); SimpleDateFormat fordate = new SimpleDateFormat("yyyy-MM-dd"); String time = fordate.format(date); try {//from www.ja v a 2 s .c om date = fordate.parse(time); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } return date; }