List of usage examples for java.text ParseException printStackTrace
public void printStackTrace()
From source file:Main.java
public static Date parseISO8601Date(String date) { if (date.length() > ISO8601_SHORT.length()) { return parseRFC3339Date(date); }// w w w. ja va 2s . c o m Date result = null; if (date.length() == "YYYYMMDD".length()) { date = date.substring(0, 4) + "-" + date.substring(4, 6) + "-" + date.substring(6, 8); } SimpleDateFormat format = ISO8601ShortFormatter.get(); try { result = format.parse(date); } catch (ParseException e) { e.printStackTrace(); } return result; }
From source file:com.bootcamp.utils.DateUtils.java
public static Date getDateStart(Date date) { if (date == null) { return null; }/*from w w w .j av a 2 s . c o m*/ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { date = sdf.parse(formatDate(date, "yyyy-MM-dd") + " 00:00:00"); } catch (ParseException e) { e.printStackTrace(); } return date; }
From source file:com.bootcamp.utils.DateUtils.java
public static Date getDateEnd(Date date) { if (date == null) { return null; }// www.j a va 2 s . co m SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { date = sdf.parse(formatDate(date, "yyyy-MM-dd") + " 23:59:59"); } catch (ParseException e) { e.printStackTrace(); } return date; }
From source file:Main.java
public static int compareDates(String startDateString, String endDateString) { int interval = 0; if (TextUtils.isEmpty(startDateString) || TextUtils.isEmpty(endDateString)) { return -1; }//from w ww .ja v a 2s . c o m try { java.util.Date startDate = dateFormat.parse(startDateString); java.util.Date endDate = dateFormat.parse(endDateString); if (startDate.after(endDate)) { return -1; } interval = compareDates(startDate, endDate); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } return interval; }
From source file:com.example.mego.adas.videos.api.YouTubeApiUtilities.java
/** * return a DataSend object to parse it to extract the time and date */// w w w . ja v a 2 s . c om public static Date fromISO8601(String publishedDate) { Date date = null; ISO8601DateFormat dateFormat = new ISO8601DateFormat(); try { date = dateFormat.parse(publishedDate); } catch (ParseException e) { e.printStackTrace(); } return date; }
From source file:Main.java
public static Date parseRFC3339Date(String date) { Date result = null;/*w ww .j a va2 s. c o m*/ SimpleDateFormat format = RFC3339Formatter.get(); boolean isLocal = date.endsWith("Z"); if (date.contains(".")) { // remove secfrac int fracIndex = date.indexOf("."); String first = date.substring(0, fracIndex); String second = null; if (isLocal) { second = date.substring(date.length() - 1); } else { if (date.contains("+")) { second = date.substring(date.indexOf("+")); } else { second = date.substring(date.indexOf("-")); } } date = first + second; } if (isLocal) { try { result = format.parse(date); } catch (ParseException e) { e.printStackTrace(); } } else { format.applyPattern(RFC3339LOCAL); // remove last colon StringBuffer buf = new StringBuffer(date.length() - 1); int colonIdx = date.lastIndexOf(':'); for (int x = 0; x < date.length(); x++) { if (x != colonIdx) buf.append(date.charAt(x)); } String bufStr = buf.toString(); try { result = format.parse(bufStr); } catch (ParseException e) { e.printStackTrace(); Log.e(TAG, "Unable to parse date"); } finally { format.applyPattern(RFC3339UTC); } } return result; }
From source file:nl.igorski.lib.utils.network.ResponseParser.java
public static String parse(HttpResponse response) { String response_text = null;// w ww . java2s. com HttpEntity entity = null; try { entity = response.getEntity(); response_text = _getResponseBody(entity); } catch (ParseException e) { e.printStackTrace(); } catch (IOException e) { if (entity != null) { try { entity.consumeContent(); } catch (IOException e1) { } } } return response_text; }
From source file:Main.java
public static String getTime(String user_time) { String re_time = null;/* w w w .jav a 2 s . com*/ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date d; try { d = sdf.parse(user_time); long l = d.getTime(); String str = String.valueOf(l); // re_time = str.substring(0, 10); re_time = str; } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } return re_time; }
From source file:com.gst.common.Utils.java
public static String convertDateToURLFormat(String dateToBeConvert) { SimpleDateFormat oldFormat = new SimpleDateFormat("dd MMMMMM yyyy", Locale.US); SimpleDateFormat newFormat = new SimpleDateFormat("yyyy-MM-dd"); String reformattedStr = ""; try {/*from w w w .j av a 2 s .c om*/ reformattedStr = newFormat.format(oldFormat.parse(dateToBeConvert)); } catch (final ParseException e) { e.printStackTrace(); } return reformattedStr; }
From source file:com.prashsoft.javakiva.KivaUtil.java
public static Date getDateFromISO8601(String iso8601Date) { SimpleDateFormat sdf = new SimpleDateFormat(ISO_8601_DATE_FORMAT); try {// w w w . j a v a2 s . c o m return sdf.parse(iso8601Date); } catch (ParseException e) { e.printStackTrace(); return null; } }