List of usage examples for java.text ParseException printStackTrace
public void printStackTrace()
From source file:Main.java
public static Date getDateFromString(String format, String time) { try {//from w ww .j av a 2 s. co m SimpleDateFormat sdf = new SimpleDateFormat(format); Date date = sdf.parse(time); return date; } catch (ParseException e) { e.printStackTrace(); } return null; }
From source file:Main.java
public static Date getDateFromString(String timeStr, String format) { SimpleDateFormat dateFormat = new SimpleDateFormat(format); try {/*from w w w . j ava2s .c om*/ return dateFormat.parse(timeStr); } catch (ParseException e) { e.printStackTrace(); } return null; }
From source file:Main.java
public static Date getSqlDate(int day, int month, int year) { java.sql.Date sqlDate = null; try {/*from ww w. j a v a2s . co m*/ java.util.Date utilDate = new SimpleDateFormat("dd/M/yyyy").parse(day + "/" + month + "/" + year); sqlDate = new java.sql.Date(utilDate.getTime()); } catch (ParseException e) { e.printStackTrace(); } return sqlDate; }
From source file:Main.java
public static Date dateFormat(String arcTime, String format) { SimpleDateFormat formatSrc = new SimpleDateFormat(format); Date date = null;//from w ww .ja va 2 s. c o m try { date = formatSrc.parse(arcTime); } catch (ParseException e) { e.printStackTrace(); } return date; }
From source file:Main.java
public static Date parseStringToDate(String formatDate, String inputDate) { SimpleDateFormat formatter = new SimpleDateFormat(formatDate); try {//from w w w . j a v a2s . c o m Date date = formatter.parse(inputDate); return date; } catch (ParseException e) { e.printStackTrace(); return null; } }
From source file:Main.java
public static Date ParseDate(String str) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); Date addTime = null;//from w w w . jav a 2 s . com try { addTime = dateFormat.parse(str); } catch (ParseException e) { e.printStackTrace(); } return addTime; }
From source file:Main.java
public static Date formatDate(String datetime) { try {/*w w w. j a v a2s .c om*/ return dateTimeFormat.parse(datetime); } catch (ParseException e) { e.printStackTrace(); } return new Date(); }
From source file:Main.java
public static Long dateStrToLong(String str) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date addTime = null;/*from w w w. jav a 2 s . com*/ try { addTime = dateFormat.parse(str); } catch (ParseException e) { e.printStackTrace(); } return addTime.getTime(); }
From source file:Main.java
public static Date formatDate(String releaseDate) { Date formattedDate = new Date(); try {//w w w .ja v a 2 s . co m formattedDate = new SimpleDateFormat("yyyy-MM-dd").parse(releaseDate); } catch (ParseException e) { e.printStackTrace(); } return formattedDate; }
From source file:Main.java
public static long getMs(String str, String format) { SimpleDateFormat sdf = new SimpleDateFormat(format); try {/*w w w .j av a 2 s .c o m*/ Date date = sdf.parse(str); return date.getTime(); } catch (ParseException e) { e.printStackTrace(); return 0; } }