List of usage examples for java.text ParseException printStackTrace
public void printStackTrace()
From source file:Main.java
@SuppressLint("SimpleDateFormat") public static String timeFormat(String data) { String time = null;// ww w . j a v a2 s.c om SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { time = sdf.format(sdf.parse(data)); } catch (ParseException e) { e.printStackTrace(); } return time; }
From source file:Main.java
public static Calendar getDateFromString(String strDate) { Calendar date = Calendar.getInstance(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy"); try {// www . j a v a 2 s . com date.setTime(simpleDateFormat.parse(strDate)); } catch (ParseException e) { e.printStackTrace(); } return date; }
From source file:Main.java
public static long dateToMilli(String dateString) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); sdf.setTimeZone(TimeZone.getDefault()); try {//w ww .j a v a 2 s. c o m return sdf.parse(dateString).getTime(); } catch (ParseException e) { e.printStackTrace(); } return 0; }
From source file:Main.java
public static Date getDateFromDateStringWithoutss(String dateStr, String template) { SimpleDateFormat formatter;/*w w w . java2s . co m*/ Date date = null; formatter = new SimpleDateFormat(template, java.util.Locale.CHINA); try { date = (Date) formatter.parse(dateStr); } catch (ParseException e) { e.printStackTrace(); } return date; }
From source file:Main.java
public static Date stringToDate(String dateString) { SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm", Locale.ENGLISH); try {/*w ww .j av a 2 s.co m*/ return format.parse(dateString); } catch (ParseException e) { e.printStackTrace(); } return null; }
From source file:Main.java
public static Date dateFormatter(String dateString) { DateFormat formatter = new SimpleDateFormat("DD-MM-yyyy"); Date date;/*from w w w .j av a 2 s . c o m*/ try { date = (Date) formatter.parse(dateString); return date; } catch (ParseException e) { e.printStackTrace(); } return null; }
From source file:Main.java
public synchronized static Date parseDate(String str) { try {/*from w w w .jav a 2s . c o m*/ Date date = iso8601Format.parse(str); return date; } catch (ParseException e) { e.printStackTrace(); return new Date(0); } }
From source file:Main.java
public static long getStringToDate(String time, String format) { SimpleDateFormat sdf = new SimpleDateFormat(format); Date date = new Date(); try {/*from w w w . j a v a 2 s . c o m*/ date = sdf.parse(time); } catch (ParseException e) { e.printStackTrace(); } return date.getTime(); }
From source file:Main.java
public static Date getDateTime(String dateTime) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.getDefault()); Date date = null;/* w w w. j a v a 2 s . c o m*/ try { date = dateFormat.parse(dateTime); } catch (ParseException e) { e.printStackTrace(); } return date; }
From source file:Main.java
public static Date getDateByCalendar(String year, String month, String day) { Date date = null;//from w ww.j a va 2s . c o m try { date = format.parse( new StringBuffer().append(year).append("-").append(month).append("-").append(day).toString()); } catch (ParseException e) { e.printStackTrace(); } return date; }