List of usage examples for java.text ParseException getErrorOffset
public int getErrorOffset()
From source file:com.teamsun.framework.util.DateUtil.java
/** * This method generates a string representation of a date/time * in the format you specify on input/* ww w . java2 s.c om*/ * * @param aMask the date pattern the string is in * @param strDate a string representation of a date * @return a converted Date object * @see java.text.SimpleDateFormat * @throws ParseException */ public static final Date convertStringToDate(String aMask, String strDate) throws ParseException { SimpleDateFormat df = null; Date date = null; df = new SimpleDateFormat(aMask); if (log.isDebugEnabled()) { log.debug("converting '" + strDate + "' to date with mask '" + aMask + "'"); } try { date = df.parse(strDate); } catch (ParseException pe) { //log.error("ParseException: " + pe); throw new ParseException(pe.getMessage(), pe.getErrorOffset()); } return (date); }
From source file:org.musicrecital.util.DateUtil.java
/** * This method generates a string representation of a date/time * in the format you specify on input//from w w w . j a va2 s . com * * @param aMask the date pattern the string is in * @param strDate a string representation of a date * @return a converted Date object * @throws ParseException when String doesn't match the expected format * @see java.text.SimpleDateFormat */ public static Date convertStringToDate(String aMask, String strDate) throws ParseException { SimpleDateFormat df; Date date; df = new SimpleDateFormat(aMask); if (log.isDebugEnabled()) { log.debug("converting '" + strDate + "' to date with mask '" + aMask + "'"); } try { date = df.parse(strDate); } catch (ParseException pe) { //log.error("ParseException: " + pe); throw new ParseException(pe.getMessage(), pe.getErrorOffset()); } return (date); }
From source file:com.gisgraphy.util.DateUtil.java
/** * This method generates a string representation of a date/time in the * format you specify on input//from ww w . j a va 2 s . c o m * * @param aMask * the date pattern the string is in * @param strDate * a string representation of a date * @return a converted Date object * @see java.text.SimpleDateFormat * @throws ParseException * when String doesn't match the expected format */ public static Date convertStringToDate(String aMask, String strDate) throws ParseException { SimpleDateFormat df; Date date; df = new SimpleDateFormat(aMask); if (log.isDebugEnabled()) { log.debug("converting '" + strDate + "' to date with mask '" + aMask + "'"); } try { date = df.parse(strDate); } catch (ParseException pe) { // log.error("ParseException: " + pe); throw new ParseException(pe.getMessage(), pe.getErrorOffset()); } return (date); }
From source file:com.gisgraphy.util.DateUtil.java
/** * This method converts a String to a date using the datePattern * //from w w w. j av a 2 s. c o m * @param strDate * the date to convert (in format MM/dd/yyyy) * @return a date object * @throws ParseException * when String doesn't match the expected format */ public static Date convertStringToDate(String strDate) throws ParseException { Date aDate = null; try { if (log.isDebugEnabled()) { log.debug("converting date with pattern: " + getDatePattern()); } aDate = convertStringToDate(getDatePattern(), strDate); } catch (ParseException pe) { log.error("Could not convert '" + strDate + "' to a date, throwing exception"); throw new ParseException(pe.getMessage(), pe.getErrorOffset()); } return aDate; }
From source file:com.teamsun.framework.util.DateUtil.java
/** * This method converts a String to a date using the datePattern * //from w ww . j av a 2 s .c o m * @param strDate the date to convert (in format yyyy-MM-dd) * @return a date object * * @throws ParseException */ public static Date convertStringToDate(String strDate) throws ParseException { Date aDate = null; try { if (log.isDebugEnabled()) { log.debug("converting date with pattern: " + datePattern); } aDate = convertStringToDate(datePattern, strDate); } catch (ParseException pe) { log.error("Could not convert '" + strDate + "' to a date, throwing exception"); pe.printStackTrace(); throw new ParseException(pe.getMessage(), pe.getErrorOffset()); } return aDate; }
From source file:org.openhie.openempi.util.DateUtil.java
/** * This method converts a String to a date using the datePattern * /*from ww w.j av a 2 s . c om*/ * @param strDate the date to convert (in format MM/dd/yyyy) * @return a date object * @throws ParseException when String doesn't match the expected format */ public static Date convertStringToDate(String strDate) throws ParseException { Date aDate = null; try { if (log.isDebugEnabled()) { log.debug("converting date with pattern: " + getDatePattern()); } aDate = convertStringToDate(getDatePattern(), strDate); } catch (ParseException pe) { log.error("Could not convert '" + strDate + "' to a date, throwing exception"); pe.printStackTrace(); throw new ParseException(pe.getMessage(), pe.getErrorOffset()); } return aDate; }
From source file:net.naijatek.myalumni.util.date.DateConverterUtil.java
/** * This method converts a String to a date using the datePattern * /*from w ww .j av a 2 s . c o m*/ * @param strDate the date to convert (in format MM/dd/yyyy) * @return a date object * * @throws ParseException */ public static Date convertStringToDate(String strDate) throws ParseException { Date aDate = null; try { if (log.isDebugEnabled()) { log.debug("converting date with pattern: " + getDatePattern()); } aDate = convertStringToDate(getDatePattern(), strDate); } catch (ParseException pe) { log.error("Could not convert '" + strDate + "' to a date, throwing exception"); pe.printStackTrace(); throw new ParseException(pe.getMessage(), pe.getErrorOffset()); } return aDate; }
From source file:com.thoughtworks.go.config.BackupConfig.java
private void validateTimer() { if (isBlank(schedule)) { return;/* w ww. ja v a 2s. c o m*/ } try { new CronExpression(schedule); } catch (ParseException pe) { errors.add(SCHEDULE, "Invalid cron syntax for backup configuration at offset " + pe.getErrorOffset() + ": " + pe.getMessage()); } }
From source file:com.anrisoftware.fractions.format.FractionFormat.java
/** * Parses the specified string to a continued fraction. * <p>//from w w w.j a v a 2s . c o m * <h2>Format</h2> * <p> * <ul> * <li>{@code "[n0;n1,...,ni]"} * </ul> * * @return the parsed {@link ContinuedFraction}. */ @Override public Object parseObject(String source, ParsePosition pos) { try { return parse(source, pos); } catch (ParseException e) { pos.setErrorIndex(pos.getIndex() + e.getErrorOffset()); return null; } }
From source file:com.turborep.turbotracker.home.WeatherSer.java
public ArrayList<WeatherForecastBean> getWeathrtForecast() throws WeatherException, ParseException { WeatherForecastBean aWeatherForecastBean = null; String aStr = connectWebservice(); ArrayList<WeatherForecastBean> aWeatherForecastList = new ArrayList<WeatherForecastBean>(); try {/*from w w w . ja va 2 s . c om*/ String aCurrentweatherDesc; JSONObject aWeatherObj = new JSONObject(aStr).getJSONObject("data"); WeatherForecastBean aCurrentWeatherBean = new WeatherForecastBean(); JSONObject aCurrentWeatherObj = aWeatherObj.getJSONArray("current_condition").getJSONObject(0); JSONArray aWeatherDescObj = aCurrentWeatherObj.getJSONArray("weatherDesc"); JSONObject aCurrDescObj = (JSONObject) aWeatherDescObj.get(0); aCurrentweatherDesc = aCurrDescObj.getString("value"); aCurrentWeatherBean.setItsCurrentWeatherDescription(aCurrentweatherDesc); aCurrentWeatherBean.setItsCurrentTempCelc(aCurrentWeatherObj.getInt("temp_C")); aCurrentWeatherBean.setItsCurrentWeatherIconlocation( ((JSONObject) aCurrentWeatherObj.getJSONArray("weatherIconUrl").get(0)).getString("value")); aWeatherForecastList.add(aCurrentWeatherBean); JSONArray aWeatherArray = aWeatherObj.getJSONArray("weather"); for (int index = 0; index < aWeatherArray.length(); index++) { aWeatherForecastBean = new WeatherForecastBean(); JSONObject aWeatherForecastArr = aWeatherArray.getJSONObject(index); aWeatherForecastBean.setItsForecastDate(aWeatherForecastArr.getString("date")); aWeatherForecastBean.setItsMaxTempCelc((int) aWeatherForecastArr.getInt("tempMaxC")); aWeatherForecastBean.setItsMinTempCelc((int) aWeatherForecastArr.getInt("tempMinC")); aWeatherForecastBean.setItsMaxTempFH((int) aWeatherForecastArr.getInt("tempMaxF")); aWeatherForecastBean.setItsMinTempFH((int) aWeatherForecastArr.getInt("tempMinF")); aWeatherForecastBean.setItsWeatherDescription( ((JSONObject) aWeatherForecastArr.getJSONArray("weatherDesc").get(0)).getString("value")); aWeatherForecastBean.setItsWeatherIconlocation( ((JSONObject) aWeatherForecastArr.getJSONArray("weatherIconUrl").get(0)) .getString("value")); aWeatherForecastList.add(aWeatherForecastBean); } } catch (ParseException e) { logger.error(e.getMessage(), e); ParseException aParseException = new ParseException(e.getMessage(), e.getErrorOffset()); throw aParseException; } catch (Exception e) { logger.error(e.getMessage(), e); WeatherException aWeatherException = new WeatherException(e.getMessage(), e); throw aWeatherException; } return aWeatherForecastList; }