List of usage examples for java.text ParseException getMessage
public String getMessage()
From source file:Main.java
public static long getGMTTime(String strGMTTime) { long millisecond = 0; try {//w ww . jav a 2 s .c o m millisecond = GMTTimeFormatter.parse(strGMTTime).getTime(); } catch (ParseException e) { if (strGMTTime.length() > 0) e.printStackTrace(); else System.err.println(e.getMessage()); } return millisecond; }
From source file:com.github.devnied.emvnfccard.utils.TrackUtils.java
/** * Extract track 2 data/*from w ww. j ava 2 s . c o m*/ * * @param pEmvCard * Object card representation * @param pData * data to parse * @return true if the extraction succeed false otherwise */ public static boolean extractTrack2Data(final EmvCard pEmvCard, final byte[] pData) { boolean ret = false; byte[] track2 = TlvUtil.getValue(pData, EmvTags.TRACK_2_EQV_DATA, EmvTags.TRACK2_DATA); if (track2 != null) { String data = BytesUtils.bytesToStringNoSpace(track2); Matcher m = TRACK2_PATTERN.matcher(data); // Check pattern if (m.find()) { // read card number pEmvCard.setCardNumber(m.group(1)); // Read expire date SimpleDateFormat sdf = new SimpleDateFormat("yyMM", Locale.getDefault()); try { pEmvCard.setExpireDate(DateUtils.truncate(sdf.parse(m.group(2)), Calendar.MONTH)); } catch (ParseException e) { LOGGER.error("Unparsable expire card date : {}", e.getMessage()); return ret; } // Read service pEmvCard.setService(new Service(m.group(3))); ret = true; } } return ret; }
From source file:com.clustercontrol.jobmanagement.util.TimeToANYhourConverter.java
public static boolean main() { String a = "2009/04/19 12:23:01"; String b = "2009/04/22 12:23:00"; String c = "2009/05/20 12:23:00"; String d = "2010/04/20 12:23:00"; String e = "2009/04/19 12:24:00"; String f = "2009/04/19 13:23:00"; String g = "2009/04/19 12:24:01"; String h = "2009/04/19 13:23:01"; String i = "2009/04/19 12:23:00"; SimpleDateFormat DFYS = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); DFYS.setTimeZone(TimezoneUtil.getTimeZone()); Date ta = null;/*from w w w. ja v a 2 s . c o m*/ Date tb = null; Date tc = null; Date td = null; Date te = null; Date tf = null; Date tg = null; Date th = null; Date ti = null; try { ta = DFYS.parse(a); tb = DFYS.parse(b); tc = DFYS.parse(c); td = DFYS.parse(d); te = DFYS.parse(e); tf = DFYS.parse(f); tg = DFYS.parse(g); th = DFYS.parse(h); ti = DFYS.parse(i); } catch (java.text.ParseException z) { m_log.debug(z.getMessage(), z); throw new InternalError(z.getMessage()); } long s = ta.getTime(); long e1 = tb.getTime(); long e2 = tc.getTime(); long e3 = td.getTime(); long e4 = te.getTime(); long e5 = tf.getTime(); long e6 = tg.getTime(); long e7 = th.getTime(); long e8 = ti.getTime(); m_log.info("from date = : " + a); m_log.info("test case 1 :>>>>>>>>>>>>"); m_log.info("to date = : " + b); m_log.info("diffTime = : " + toDiffTime(s, e1)); m_log.info("test case 2 :>>>>>>>>>>>>"); m_log.info("to date = : " + c); m_log.info("diffTime = : " + toDiffTime(s, e2)); m_log.info("test case 3 :>>>>>>>>>>>>"); m_log.info("to date = : " + d); m_log.info("diffTime = : " + toDiffTime(s, e3)); m_log.info("test case 4 :>>>>>>>>>>>>"); m_log.info("to date = : " + e); m_log.info("diffTime = : " + toDiffTime(s, e4)); m_log.info("test case 5 :>>>>>>>>>>>>"); m_log.info("to date = : " + f); m_log.info("diffTime = : " + toDiffTime(s, e5)); m_log.info("test case 6 :>>>>>>>>>>>>"); m_log.info("to date = : " + g); m_log.info("diffTime = : " + toDiffTime(s, e6)); m_log.info("test case 7 :>>>>>>>>>>>>"); m_log.info("to date = : " + h); m_log.info("diffTime = : " + toDiffTime(s, e7)); m_log.info("test case 8 :>>>>>>>>>>>>"); m_log.info("to date = : " + a); m_log.info("diffTime = : " + toDiffTime(s, s)); m_log.info("test case 9 :>>>>>>>>>>>>"); m_log.info("to date = : " + i); m_log.info("diffTime = : " + toDiffTime(s, e8)); return true; }
From source file:com.worldline.easycukes.rest.utils.DateHelper.java
/** * Used to get date value//from w w w .j a v a2s .com * * @return * @throws ParseException */ public static String parseDateToJson(@NonNull final String sDate) throws ParseException { log.info("Parsing date " + sDate); if (sDate == null) return null; final Calendar calendar = Calendar.getInstance(); final SimpleDateFormat simpleDateFormat = new SimpleDateFormat( ExecutionContext.get(RestConstants.DATE_FORMAT)); try { calendar.setTime(simpleDateFormat.parse(sDate)); return convertDateToJsonFormat(calendar.getTime()); } catch (final ParseException e) { log.error(e.getMessage(), e); throw e; } }
From source file:mServer.tool.MserverDatumZeit.java
/** * formats a date/datetime string to the date format used in DatenFilm * @param dateValue the date/datetime value * @param sdf the format of dateValue//from ww w .j a v a2 s.c o m * @return the formatted date string */ public static String formatDate(String dateValue, FastDateFormat sdf) { try { return FDF_OUT_DAY.format(sdf.parse(dateValue)); } catch (ParseException ex) { LOG.debug(String.format("Fehler beim Parsen des Datums %s: %s", dateValue, ex.getMessage())); } return ""; }
From source file:mServer.tool.MserverDatumZeit.java
/** * formats a datetime string to the time format used in DatenFilm * @param dateValue the datetime value/*from w w w.j av a 2 s . c o m*/ * @param sdf the format of dateValue * @return the formatted time string */ public static String formatTime(String dateValue, FastDateFormat sdf) { try { return FDF_OUT_TIME.format(sdf.parse(dateValue)); } catch (ParseException ex) { LOG.debug(String.format("Fehler beim Parsen des Datums %s: %s", dateValue, ex.getMessage())); } return ""; }
From source file:de.terrestris.shogun.deserializer.DateDeserializer.java
/** * This method tries to convert a passed date string into a date. * * Currently only strings formatted as <code>dd.MM.yyyy HH:mm:ss</code> are * supported.//from ww w. ja va 2s .c o m * * @param jsonStr * @return a <code>Date</code>-object or null. */ public static Date parseCommonlyFormattedDate(String jsonStr) { SimpleDateFormat parserSDF = new SimpleDateFormat(DATE_FORMAT); parserSDF.setLenient(false); Date parsedDate = null; String failNotice = "Failed to parse string '" + jsonStr + "' with format '" + DATE_FORMAT + "'"; try { parsedDate = parserSDF.parse(jsonStr); } catch (ParseException e) { LOGGER.error(failNotice + ": " + e.getMessage()); } if (parsedDate == null) { LOGGER.info(failNotice); } return parsedDate; }
From source file:com.hagreve.android.lib.HaGreveApi.java
/** * Obtains the list of current strikes./*from www . j a va2 s. co m*/ * @return Array of Strike objects */ public static Strike[] getStrikes() { Strike[] items = new Strike[0]; String result = doGetRequest(BASE_URL + "/strikes"); if (result != null) { GsonBuilder builder = new GsonBuilder(); builder.registerTypeAdapter(Date.class, new JsonDeserializer<Date>() { public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { return formatter.parse(json.getAsString()); } catch (ParseException e) { throw new JsonParseException(e.getMessage()); } } }); Gson gson = builder.create(); items = gson.fromJson(result, Strike[].class); } return items; }
From source file:com.collabnet.ccf.core.utils.DateUtil.java
private static Date parse(String dateString, DateFormat dateFormat) { try {/* w w w . j a v a2 s. c o m*/ return dateFormat.parse(dateString); } catch (ParseException e) { log.error("ParseException: " + e.getMessage()); } return null; }
From source file:com.greenline.guahao.biz.manager.partners.xm.converter.XmConverter.java
/** * ??// w w w .j ava 2 s .c o m * * @param yyyyMMdd yyyyMMdd? * @return */ private static long parseTimeToSecondFromYyyyMMdd(String yyyyMMdd) { long time = 0; if (null != yyyyMMdd) { SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); Date date = null; try { date = sdf.parse(yyyyMMdd); } catch (ParseException e) { log.error(String.format("?%s", e.getMessage()), e); } time = parseTimeToSecond(date); } return time; }