List of usage examples for java.text ParseException getMessage
public String getMessage()
From source file:org.languagetool.dev.wikipedia.CheckWikipediaDump.java
@SuppressWarnings("AccessStaticViaInstance") private static CommandLine ensureCorrectUsageOrExit(String[] args) { Options options = new Options(); options.addOption(OptionBuilder.withLongOpt("language").withArgName("code").hasArg() .withDescription("language code like 'en' or 'de'").isRequired().create("l")); options.addOption(OptionBuilder.withLongOpt("db-properties").withArgName("file").hasArg().withDescription( "A file to set database access properties. If not set, the output will be written to STDOUT. " + "The file needs to set dbDriver (fully qualified driver class), dbUrl ('jdbc:...'), dbUser, and dbPassword.") .create("d")); options.addOption(OptionBuilder.withLongOpt("rule-properties").withArgName("file").hasArg().withDescription( "A file to set rules which should be disabled per language (e.g. en=RULE1,RULE2 or all=RULE3,RULE4)") .create());/* ww w . j av a 2s . c o m*/ options.addOption(OptionBuilder.withLongOpt("rule-ids").withArgName("id").hasArg() .withDescription("comma-separated list of rule-ids to activate").create("r")); options.addOption(OptionBuilder.withLongOpt("file").withArgName("xmlfile").hasArg().withDescription( "an unpacked Wikipedia XML dump; dumps are available from http://dumps.wikimedia.org/backup-index.html") .isRequired().create("f")); options.addOption(OptionBuilder.withLongOpt("max-articles").withArgName("number").hasArg() .withDescription("maximum number of articles to check").create()); options.addOption(OptionBuilder.withLongOpt("max-errors").withArgName("number").hasArg() .withDescription("maximum number of errors, stop when finding more").create()); try { CommandLineParser parser = new GnuParser(); return parser.parse(options, args); } catch (org.apache.commons.cli.ParseException e) { System.err.println("Error: " + e.getMessage()); HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(80); formatter.setSyntaxPrefix("Usage: "); formatter.printHelp( CheckWikipediaDump.class.getSimpleName() + " [OPTION]... --file <xmlfile> --language <code>", options); System.exit(1); } return null; }
From source file:com.trial.phonegap.plugin.calendar.CalendarAccessorMock.java
/** * Parse a String into Date, with format yyyy-MM-dd HH:mm:ss * @param dateString// w w w . j a v a 2s.com * @return */ private static Date stringToDate(String dateString) { Date date = null; SimpleDateFormat dformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { date = dformat.parse(dateString); //its normal having an parsing exception here, for instance, with "No Credit" as string } catch (ParseException parseException) { Log.i(LOG_TAG, parseException.getMessage()); return null; } return date; }
From source file:org.cesecore.util.ValidityDate.java
/** * Parse a date as either "yyyy-MM-dd HH:mm:ssZZ" or a relative hex encoded UNIX time stamp (in seconds). * Use for parsing of the build time property "ca.toolateexpiredate" in ejbca.properties. * @return the date or the largest possible Date if unable to parse the argument. */// w ww .j av a 2 s . c o m public static Date parseCaLatestValidDateTime(final String sDate) { Date tooLateExpireDate = null; if (sDate.length() > 0) { //First, try to parse the date in ISO8601 date time format. try { return parseAsIso8601(sDate); } catch (ParseException e) { log.debug("tooLateExpireDate could not be parsed as an ISO8601 date: " + e.getMessage()); } // Second, try to parse it as a hexadecimal value (without markers of any kind.. just a raw value). if (tooLateExpireDate == null) { try { tooLateExpireDate = new Date(Long.parseLong(sDate, 16) * 1000); } catch (NumberFormatException e) { log.debug("tooLateExpireDate could not be parsed as a hex value: " + e.getMessage()); } } } if (tooLateExpireDate == null) { log.debug("Using default value for ca.toolateexpiredate."); tooLateExpireDate = new Date(Long.MAX_VALUE); } else if (log.isDebugEnabled()) { log.debug("tooLateExpireData is set to: " + tooLateExpireDate); } return tooLateExpireDate; }
From source file:com.arvato.thoroughly.util.CommonUtils.java
public static Date lastSecondOfTheDayTime(String source) throws TmallAppException { SimpleDateFormat ymd = new SimpleDateFormat("yyyy-MM-dd", Locale.CHINA); SimpleDateFormat ymdhms = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA); Date newDate = null;/*from w ww. j a v a 2 s .co m*/ try { Date oldDate = ymd.parse(source); newDate = ymdhms.parse(ymd.format(oldDate) + " 23:59:59"); } catch (ParseException e) { LOGGER.error(e.getMessage(), e); throw new TmallAppException(ResponseCode.INTERNAL_SERVER_ERROR.getCode(), e.getMessage()); } return newDate; }
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// ww w .j a v a 2 s . co 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.espertech.esper.client.util.DateTime.java
private static Date parse(String str, SimpleDateFormat format) { Date d;/* ww w . j ava 2 s.c om*/ try { d = format.parse(str); } catch (ParseException e) { log.warn("Error parsing date '" + str + "' according to format '" + format.toPattern() + "': " + e.getMessage(), e); return null; } return d; }
From source file:com.abuabdul.mytravelpal.util.MyTravelPalFunc.java
public static final List<CalendarEvent> fromTravelPalToCalendarEvent(List<MyTravelPal> plans) throws ParseException { return Lists.transform(plans, new Function<MyTravelPal, CalendarEvent>() { @Override//from ww w .java 2 s. c o m public CalendarEvent apply(MyTravelPal plan) { CalendarEvent event = new CalendarEvent(); try { event.setId(plan.getId()); event.setTitle(plan.getTravelPlanDesc()); event.setStart(dateISO8601(plan.getStartDate()) + (isNotEmpty(plan.getStartTime()) ? "T" + plan.getStartTime() : "")); event.setEnd(isNotEmpty(plan.getEndDate()) ? dateISO8601(plan.getEndDate()) + (isNotEmpty(plan.getEndTime()) ? "T" + plan.getEndTime() : "") : ""); event.setEndTimeHoverMsg(plan.getEndTime()); event.setTravelMode(plan.getTravelMode()); event.setTravelType(plan.getTravelType()); event.setSideNote(plan.getSideNote()); } catch (ParseException ex) { log.warn("Cannot parse corrupt dates. " + ex.getMessage()); } return event; } }); }
From source file:gov.nih.nci.ess.ae.GridToDomainObjectConverter.java
/** * ISO 21090 date to {@link Date}.//from ww w . j a v a 2 s . co m * * @param tsDateTime * @return */ public static Date convertToDate(TS tsDateTime) { try { if (tsDateTime != null && tsDateTime.getNullFlavor() == null) { String value = tsDateTime.getValue(); if (value != null) { return DateUtils.parseDate(value, new String[] { TS_DATETIME_PATTERN }); } } } catch (ParseException e) { log.error(e.getMessage(), e); } return null; }
From source file:com.hurence.logisland.utils.DateUtils.java
public static Date getDateFromLogString(String dateString) { SimpleDateFormat sdf = new SimpleDateFormat("dd/MMM/yyyy:hh:mm:ss", new Locale("en", "US")); sdf.setTimeZone(tz);/*from w w w . j a v a 2 s . c o m*/ Date result = null; try { result = sdf.parse(dateString); } catch (ParseException e) { log.warn(e.getMessage()); } return result; }
From source file:org.eclipse.gyrex.jobs.internal.schedules.ScheduleEntryImpl.java
public static void validateCronExpression(final String expression) throws IllegalArgumentException { final String[] tokens = StringUtils.split(expression); if ((tokens.length < 5) || (tokens.length > 6)) throw new IllegalArgumentException( "A cron expression must consist of five to six tokens (<Minute> <Hour> <Day_of_the_Month> <Month_of_the_Year> <Day_of_the_Week> <Year>)."); if (CronExpression.isValidExpression(Schedule.asQuartzCronExpression(expression))) return;/*w ww. j a v a 2 s . c om*/ try { new CronExpression(Schedule.asQuartzCronExpression(expression)); // no exception but still invalid throw new IllegalArgumentException("invalid cron expression: " + expression); } catch (final ParseException e) { throw new IllegalArgumentException(e.getMessage(), e); } }