List of usage examples for java.text ParseException printStackTrace
public void printStackTrace()
From source file:Main.java
public static Date strToTime(String str) { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); Date date = null;/*from w w w .ja v a 2s . c o m*/ try { date = format.parse(str); } catch (ParseException e) { e.printStackTrace(); } return date; }
From source file:Main.java
public static Date getDateByFormat(String strDate, String format) { SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat(format, Locale.CHINA); Date date = null;//from w w w.j a v a 2s .c o m try { date = mSimpleDateFormat.parse(strDate); } catch (ParseException e) { e.printStackTrace(); } return date; }
From source file:Main.java
public static Date stringDateToDate(String StrDate) { Date dateToReturn = null;//from ww w .j a v a2 s. c om SimpleDateFormat dateFormat = new SimpleDateFormat(DATEFORMAT); try { dateToReturn = (Date) dateFormat.parse(StrDate); } catch (ParseException e) { e.printStackTrace(); } return dateToReturn; }
From source file:Main.java
public static Date getDateFromFormattedStringInGMT(String str) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); Date date = null;/* w w w . j a v a 2 s. c om*/ try { date = simpleDateFormat.parse(str); } catch (ParseException e) { e.printStackTrace(); } return date; }
From source file:Main.java
public static String getFormattedDate(String date) { SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy hh:mm:ss Z"); Date newDate = null;//from w ww . jav a2s . c o m try { newDate = format.parse(date); } catch (ParseException e) { e.printStackTrace(); } format = new SimpleDateFormat("MMM dd, yyyy hh:mm a"); return format.format(newDate); }
From source file:Main.java
/** * time: 2016/10/19 11:42/*w w w. j a v a 2 s . c o m*/ * description: */ public static Date getData(String time) { SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd"); try { Date parse = myFormatter.parse(time); return parse; } catch (ParseException e) { e.printStackTrace(); } return null; }
From source file:Main.java
public static int getDayOFYear(String date) { try {// w w w . j a v a2 s . co m Date parse = yearFormat.parse(date); Calendar instance = Calendar.getInstance(); instance.setTime(parse); return instance.get(Calendar.DAY_OF_YEAR); } catch (ParseException e) { e.printStackTrace(); } return 0; }
From source file:Main.java
public static Calendar stringToCalendar(String string) { try {//from w ww . j av a 2 s .co m SimpleDateFormat formatter = new SimpleDateFormat("yyy-MM-dd HH:mm", Locale.CHINESE); Date date = formatter.parse(string); Calendar calendar = Calendar.getInstance(); calendar.setTime(date); return calendar; } catch (ParseException e) { e.printStackTrace(); } return null; }
From source file:Main.java
public static Calendar timeStringToCalendar(String timeString) { try {// w ww . j av a2 s . c o m SimpleDateFormat formatter = new SimpleDateFormat("HH:mm", Locale.CHINESE); Date date = formatter.parse(timeString); Calendar calendar = Calendar.getInstance(); calendar.setTime(date); return calendar; } catch (ParseException e) { e.printStackTrace(); } return null; }
From source file:Main.java
public static Date StrToDate(String str) { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss"); Date date = null;/*from ww w . j a v a2 s . c om*/ try { date = format.parse(str); } catch (ParseException e) { e.printStackTrace(); } return date; }