Example usage for java.text ParseException getMessage

List of usage examples for java.text ParseException getMessage

Introduction

In this page you can find the example usage for java.text ParseException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.eclipse.smarthome.binding.astro.handler.AstroThingHandler.java

/**
 * Schedules a positional and a daily job at midnight for Astro calculation and starts it immediately too. Removes
 * already scheduled jobs first.//from   w  ww . j  ava  2s . co  m
 */
private void restartJobs() {
    logger.debug("Restarting jobs for thing {}", getThing().getUID());
    monitor.lock();
    try {
        stopJobs();
        if (getThing().getStatus() == ONLINE) {
            String thingUID = getThing().getUID().toString();
            if (scheduledExecutor == null) {
                logger.warn("Thread Pool Executor is not available");
                return;
            }
            // Daily Job
            dailyJob = getDailyJob();
            scheduledExecutor.schedule(dailyJob, new CronExpression(DAILY_MIDNIGHT));
            logger.debug("Scheduled {} at midnight", dailyJob);
            // Execute daily startup job immediately
            dailyJob.run();

            // Repeat positional job every configured seconds
            // Use scheduleAtFixedRate to avoid time drift associated with scheduleWithFixedDelay
            if (isPositionalChannelLinked()) {
                Job positionalJob = new PositionalJob(thingUID);
                ScheduledFuture<?> future = scheduler.scheduleAtFixedRate(positionalJob, 0,
                        thingConfig.getInterval(), TimeUnit.SECONDS);
                scheduledFutures.add(future);
                logger.info("Scheduled {} every {} seconds", positionalJob, thingConfig.getInterval());
            }
        }
    } catch (ParseException ex) {
        logger.error("{}", ex.getMessage(), ex);
    } finally {
        monitor.unlock();
    }
}

From source file:com.neusoft.mid.clwapi.service.news.NewsServiceImpl.java

/**
 * ???//from w  w w.j av  a2 s .  c  o m
 * 
 * @param token
 *            
 * @param body
 *            ?
 * @return
 */
@Override
public Object getNewsSummaryInfo(String token, String body) {
    logger.info("????");

    // ??
    NewsRequ iNewsRequ = JacksonUtils.fromJsonRuntimeException(body, NewsRequ.class);
    // ??
    iNewsRequ.setEndTime(StringUtils.strip(iNewsRequ.getEndTime()));
    iNewsRequ.setStartTime(StringUtils.strip(iNewsRequ.getStartTime()));
    iNewsRequ.setNum(StringUtils.strip(iNewsRequ.getNum()));
    iNewsRequ.setType(StringUtils.strip(iNewsRequ.getType()));

    // ??
    logger.info("??");
    if (StringUtils.isEmpty(iNewsRequ.getType())) {
        logger.error("??");
        throw new ApplicationException(ErrorConstant.ERROR10001, Response.Status.BAD_REQUEST);
    } else if (StringUtils.isEmpty(iNewsRequ.getStartTime()) || StringUtils.isEmpty(iNewsRequ.getEndTime())) {
        logger.error("????");
        throw new ApplicationException(ErrorConstant.ERROR10002, Response.Status.BAD_REQUEST);
    } else if (HttpConstant.TIME_15_DAY_AGO.equalsIgnoreCase(iNewsRequ.getStartTime())
            && !HttpConstant.TIME_ZERO.equals(iNewsRequ.getEndTime())) {
        logger.error(
                "??-dd15????0");
        throw new ApplicationException(ErrorConstant.ERROR10002, Response.Status.BAD_REQUEST);
    }

    // numNumnull??num?
    if (StringUtils.isEmpty(iNewsRequ.getNum())) {
        iNewsRequ.setNum(null);
    } else if (!StringUtils.isNumeric(iNewsRequ.getNum())) {
        logger.error("??num?");
        throw new ApplicationException(ErrorConstant.ERROR10002, Response.Status.BAD_REQUEST);
    }

    // ????
    if (!HttpConstant.TIME_ZERO.equals(iNewsRequ.getStartTime())
            && !HttpConstant.TIME_15_DAY_AGO.equalsIgnoreCase(iNewsRequ.getStartTime())) {
        try {
            TimeUtil.parseStringToDate(iNewsRequ.getStartTime(), HttpConstant.TIME_FORMAT);
        } catch (ParseException e) {
            logger.error("????" + e.getMessage());
            throw new ApplicationException(ErrorConstant.ERROR10002, Response.Status.BAD_REQUEST);
        }
    }
    if (!HttpConstant.TIME_ZERO.equals(iNewsRequ.getEndTime())) {
        try {
            TimeUtil.parseStringToDate(iNewsRequ.getEndTime(), HttpConstant.TIME_FORMAT);
        } catch (ParseException e) {
            logger.error("?????" + e.getMessage());
            throw new ApplicationException(ErrorConstant.ERROR10002, Response.Status.BAD_REQUEST);
        }
    }

    if (HttpConstant.TIME_ZERO.equals(iNewsRequ.getStartTime())) {
        iNewsRequ.setStartTime(null);
    } else if (HttpConstant.TIME_15_DAY_AGO.equalsIgnoreCase(iNewsRequ.getStartTime())) {
        Date dBTime = iCommonMapper.getDBTime();
        Date fifteenDayAgo = TimeUtil.get15Ago(dBTime);
        String startTime = TimeUtil.formatDateToString(fifteenDayAgo, HttpConstant.TIME_FORMAT);
        iNewsRequ.setStartTime(startTime);
    }
    if (HttpConstant.TIME_ZERO.equals(iNewsRequ.getEndTime())) {
        iNewsRequ.setEndTime(null);
    }

    // Type
    if (iNewsRequ.getType().equalsIgnoreCase("-1")) {
        iNewsRequ.setType(null);
    } else if (iNewsRequ.getType().equals("0") || iNewsRequ.getType().equals("1")) {
        // ??????
    } else {
        logger.error("??type");
        throw new ApplicationException(ErrorConstant.ERROR10002, Response.Status.BAD_REQUEST);
    }

    // 0

    logger.info("??");
    logger.info("???");

    // ???
    List<NewsInfo> list = iNewsMapper.getNewsList(iNewsRequ);
    logger.debug("list=" + (list == null ? "NULL" : list.size()));

    if (list == null || list.size() == 0) {
        logger.info("???");
        return Response.noContent().build();
    }

    logger.info("????");
    logger.debug("???");
    if (logger.isDebugEnabled()) {
        Iterator<NewsInfo> it = list.iterator();
        while (it.hasNext()) {
            NewsInfo temp = it.next();
            logger.debug(temp.toString());
        }
    }

    // ?
    Map<String, List<NewsInfo>> map = new HashMap<String, List<NewsInfo>>();
    map.put("news", list);

    logger.info("?????");
    return JacksonUtils.toJsonRuntimeException(map);
}

From source file:org.geoserver.security.iride.entity.identity.IrideIdentityValidator.java

/**
 * Validates <code>Timestamp</code> token.
 *
 * @param value/*from  www. ja  va  2  s .c om*/
 * @return
 */
private boolean isValidTimestamp(String value) {
    if (value == null) {
        return false;
    }

    try {
        this.dateFormat.parse(value);

        return true;
    } catch (ParseException e) {
        LOGGER.trace("Invalid date format: {}", e.getMessage());

        return false;
    }
}

From source file:org.apache.carbondata.processing.merger.CarbonDataMergerUtil.java

/**
 * @param loadsOfSameDate//w  ww .j  a v  a2  s .  c  o  m
 * @param segment
 * @return
 */
private static Date initializeFirstSegment(List<LoadMetadataDetails> loadsOfSameDate,
        LoadMetadataDetails segment, SimpleDateFormat sdf) {
    long baselineLoadStartTime = segment.getLoadStartTime();
    Date segDate1 = null;
    try {
        segDate1 = sdf.parse(sdf.format(baselineLoadStartTime));
    } catch (ParseException e) {
        LOGGER.error("Error while parsing segment start time" + e.getMessage(), e);
    }
    loadsOfSameDate.add(segment);
    return segDate1;
}

From source file:org.kuali.kra.coi.lookup.CoiDisclosureUndisclosedEventsLookupableHelper.java

protected boolean validateDate(String dateFieldName, String dateFieldValue) {
    try {// ww  w.j a v  a 2  s  . c  o  m
        CoreApiServiceLocator.getDateTimeService().convertToSqlTimestamp(dateFieldValue);
        return true;
    } catch (ParseException e) {
        GlobalVariables.getMessageMap().putError(dateFieldName, KeyConstants.ERROR_SEARCH_INVALID_DATE);
        return false;
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
        GlobalVariables.getMessageMap().putError(dateFieldName, KeyConstants.ERROR_SEARCH_INVALID_DATE);
        return false;
    }
}

From source file:disono.webmons.com.clean_architecture.presentation.ui.activities.communication.voice.SIPService.java

/**
 * Logs you into your SIP provider, registering this device as the location to
 * send SIP calls to for your SIP address.
 */// w w  w  . j av  a  2  s  .c  o m
private void _initializeLocalProfile() {
    if (manager == null) {
        return;
    }

    // unregister profile to server
    if (me != null) {
        _closeLocalProfile();
    }

    // SIP authentication details
    String username = "";
    String password = "";
    String domain = Configurations.envString("sipDomain");

    // check if domain configuration is set
    if (domain != null) {
        return;
    }

    // always check the variables for values
    if (username.length() == 0 || domain.length() == 0 || password.length() == 0) {
        return;
    }

    try {
        SipProfile.Builder builder = new SipProfile.Builder(username, domain);
        builder.setPassword(password);
        me = builder.build();

        // intent for incoming calls
        Intent i = new Intent();
        i.setAction("android.SipDemo.INCOMING_CALL");
        PendingIntent pi = PendingIntent.getBroadcast(this, 0, i, Intent.FILL_IN_DATA);
        manager.open(me, pi, null);

        // This listener must be added AFTER manager.open is called,
        // Otherwise the methods aren't guaranteed to fire.
        manager.setRegistrationListener(me.getUriString(), new SipRegistrationListener() {
            @Override
            public void onRegistering(String localProfileUri) {
                Log.i(TAG, "_initializeLocalProfile:Registering with SIP Server...");
            }

            @Override
            public void onRegistrationDone(String localProfileUri, long expiryTime) {
                Log.i(TAG, "_initializeLocalProfile:Ready");
                _updateStatus(0, "Ready", null);
            }

            @Override
            public void onRegistrationFailed(String localProfileUri, int errorCode, String errorMessage) {
                Log.e(TAG, "_initializeLocalProfile:Registration failed: " + errorMessage);
            }
        });
    } catch (ParseException pe) {
        Log.e(TAG, "ParseException: " + pe.getMessage());
    } catch (SipException se) {
        Log.e(TAG, "SipException: " + se.getMessage());
    }
}

From source file:com.feilong.core.date.DateUtil.java

/**
 *  <code>dateString</code> ?? <code>datePattern</code> ????date.
 * /*from  ww  w .j a  v  a 2  s .  c o  m*/
 * <h3>:</h3>
 * 
 * <blockquote>
 * 
 * <pre class="code">
 * DateUtil.toDate("2016-02-33", DatePattern.COMMON_DATE)                   = 2016-03-04
 * DateUtil.toDate("2016-06-28T01:21:12-0800", "yyyy-MM-dd'T'HH:mm:ssZ")    = 2016-06-28 17:21:12
 * DateUtil.toDate("2016-06-28T01:21:12+0800", "yyyy-MM-dd'T'HH:mm:ssZ")    = 2016-06-28 01:21:12
 * </pre>
 * 
 * </blockquote>
 * 
 * <h3>?:</h3>
 * <blockquote>
 * <ol>
 * <li>?,<b>??</b>,?? {@link java.text.DateFormat#setLenient(boolean)},??"2016-02-33",?? 2016-03-04</li>
 * <li>?,?</li>
 * <li>??,</li>
 * </ol>
 * </blockquote>
 * 
 * @param dateString
 *            
 * @param parsePatterns
 *            ?,?{@link DatePattern}
 * @return  <code>dateString</code> null, {@link NullPointerException}<br>
 *          <code>dateString</code> blank, {@link IllegalArgumentException}<br>
 *          <code>parsePatterns</code>  null, {@link NullPointerException}<br>
 * @see org.apache.commons.lang3.time.DateUtils#parseDate(String, String...)
 * @see <a href="http://stackoverflow.com/questions/4216745/java-string-to-date-conversion/">java-string-to-date-conversion</a>
 * @see <a href="http://stackoverflow.com/questions/4216745/java-string-to-date-conversion/22180505#22180505">java-string-to-date-
 *      conversion/22180505#22180505</a>
 * @see <a href="http://stackoverflow.com/questions/2735023/convert-string-to-java-util-date">convert-string-to-java-util-date</a>
 * @since 1.7.3 change param to parsePatterns array
 */
public static Date toDate(String dateString, String... parsePatterns) {
    Validate.notBlank(dateString, "dateString can't be blank!");
    Validate.notNull(parsePatterns, "parsePatterns can't be null!");
    try {
        return DateUtils.parseDate(dateString, parsePatterns);
    } catch (ParseException e) {
        String pattern = "parse dateString [{}] use patterns:[{}] to date exception,message:[{}]";
        throw new IllegalArgumentException(Slf4jUtil.format(pattern, dateString, parsePatterns, e.getMessage()),
                e);
    }
}

From source file:org.azyva.dragom.cliutil.CliUtil.java

/**
 * Helper method to return the List of root {@link ModuleVersion}'s used by many
 * tools./* www .j  a  v a 2  s .  c  om*/
 * <p>
 * If the command line specifies the --root-module-version option, no root
 * ModuleVersions's must be specified by RootManager, and the List of root
 * ModuleVerion's contains the ModuleVersion's specified by these options that
 * specify ModuleVersion literals.
 * <p>
 * Otherwise, RootManager must specify at least one root ModuleVersion and this
 * List of root ModuleVersion's specified by RootManager is returned.
 *
 * @param commandLine CommandLine. Can be null to indicate that root
 *   ModuleVersion's cannot be specified on the command line.
 * @return List of root ModuleVersion's.
 */
public static List<ModuleVersion> getListModuleVersionRoot(CommandLine commandLine) {
    String[] arrayStringRootModuleVersion;
    List<ModuleVersion> listModuleVersionRoot;

    if (commandLine != null) {
        arrayStringRootModuleVersion = commandLine
                .getOptionValues(CliUtil.getRootModuleVersionCommandLineOption());
    } else {
        arrayStringRootModuleVersion = null;
    }

    if (arrayStringRootModuleVersion != null) {
        if (!RootManager.getListModuleVersion().isEmpty()) {
            throw new RuntimeExceptionUserError(MessageFormat.format(
                    CliUtil.resourceBundle.getString(
                            CliUtil.MSG_PATTERN_KEY_ROOT_MODULE_VERSION_NOT_ALLOWED_WHEN_SPECIFIED_WORKSPACE),
                    CliUtil.getRootModuleVersionCommandLineOption(), CliUtil.getHelpCommandLineOption()));
        }

        listModuleVersionRoot = new ArrayList<ModuleVersion>();

        for (int i = 0; i < arrayStringRootModuleVersion.length; i++) {
            try {
                listModuleVersionRoot.add(ModuleVersion.parse(arrayStringRootModuleVersion[i]));
            } catch (ParseException pe) {
                throw new RuntimeExceptionUserError(MessageFormat.format(
                        CliUtil.getLocalizedMsgPattern(
                                CliUtil.MSG_PATTERN_KEY_ERROR_PARSING_COMMAND_LINE_OPTION),
                        CliUtil.getRootModuleVersionCommandLineOption(), pe.getMessage(),
                        CliUtil.getHelpCommandLineOption()));
            }
        }
    } else {
        if (RootManager.getListModuleVersion().isEmpty()) {
            if (commandLine == null) {
                throw new RuntimeExceptionUserError(MessageFormat.format(CliUtil.resourceBundle.getString(
                        CliUtil.MSG_PATTERN_KEY_ROOT_MODULE_VERSION_REQUIRED_WHEN_NOT_SPECIFIED_WORKSPACE),
                        CliUtil.getHelpCommandLineOption()));
            } else {
                throw new RuntimeExceptionUserError(MessageFormat.format(CliUtil.resourceBundle.getString(
                        CliUtil.MSG_PATTERN_KEY_ROOT_MODULE_VERSION_REQUIRED_WHEN_NOT_SPECIFIED_WORKSPACE),
                        CliUtil.getRootModuleVersionCommandLineOption(), CliUtil.getHelpCommandLineOption()));
            }
        }

        listModuleVersionRoot = RootManager.getListModuleVersion();
    }

    return listModuleVersionRoot;
}

From source file:net.sourceforge.msscodefactory.cflib.v1_11.CFLib.Swing.CFJInt16Editor.java

public boolean isEditValid() {
    final String S_ProcName = "isEditValid";
    if (!hasValue()) {
        setValue(null);/*from w  w  w  . j a v  a2s  . c  o  m*/
        return (true);
    }

    boolean retval = super.isEditValid();
    if (retval) {
        try {
            commitEdit();
        } catch (ParseException e) {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Field is not valid - " + e.getMessage(), e);

        }
        Object obj = getValue();
        if (obj == null) {
            retval = false;
        } else if (obj instanceof Short) {
            Short s = (Short) obj;
            short v = s.shortValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                retval = false;
            }
        } else if (obj instanceof Integer) {
            Integer i = (Integer) obj;
            int v = i.intValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                retval = false;
            }
        } else if (obj instanceof Long) {
            Long l = (Long) obj;
            long v = l.longValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                retval = false;
            }
        } else if (obj instanceof Number) {
            Number n = (Number) obj;
            long v = n.longValue();
            if ((v < getMinValue()) || (v > getMaxValue())) {
                retval = false;
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), S_ProcName,
                    "EditedValue", obj, "Short, Integer, Long, or Number");
        }
    }
    return (retval);
}

From source file:de.micromata.genome.logging.loghtmlwindow.LogHtmlWindowServlet.java

protected void filter(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    String logMessage = req.getParameter("logMessage");
    Integer level = null;//from   w  w w  . j  a  va  2 s  .  co  m
    String logLevel = req.getParameter("logLevel");
    if (StringUtils.isNotBlank(logLevel) == true) {
        level = LogLevel.fromString(logLevel, LogLevel.Note).getLevel();
    }
    String logCategory = req.getParameter("logCategory");

    Timestamp start = null;
    Timestamp end = null;
    List<Pair<String, String>> logAttributes = null;
    String logAttribute1Type = req.getParameter("logAttribute1Type");
    String logAttribute1Value = req.getParameter("logAttribute1Value");
    String logAttribute2Type = req.getParameter("logAttribute2Type");
    String logAttribute2Value = req.getParameter("logAttribute2Value");
    SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX", Locale.US);

    String fromDate = req.getParameter("fromDate");
    String toDate = req.getParameter("toDate");
    if (StringUtils.length(fromDate) == "yyyy-MM-ddTHH:mm:ss.SSSZ".length()) {
        try {
            start = new Timestamp(sd.parse(fromDate).getTime());
        } catch (ParseException ex) {
            LOG.warn("Cannot parse Logging fromDate: " + fromDate + ": " + ex.getMessage());
        }
    }
    if (StringUtils.length(toDate) == "yyyy-MM-ddTHH:mm:ss.SSSZ".length()) {
        try {
            end = new Timestamp(sd.parse(toDate).getTime());
        } catch (ParseException ex) {
            LOG.warn("Cannot parse Logging fromDate: " + toDate + ": " + ex.getMessage());
        }
    }
    if (StringUtils.isNotBlank(logAttribute1Type) && StringUtils.isNotBlank(logAttribute1Value)) {
        logAttributes = new ArrayList<>();
        logAttributes.add(Pair.make(logAttribute1Type, logAttribute1Value));
    }
    if (StringUtils.isNotBlank(logAttribute2Type) && StringUtils.isNotBlank(logAttribute2Value)) {
        if (logAttributes == null) {
            logAttributes = new ArrayList<>();
        }
        logAttributes.add(Pair.make(logAttribute2Type, logAttribute2Value));
    }
    List<OrderBy> orderBy = new ArrayList<>();
    String orderCol = req.getParameter("orderBy");
    if (StringUtils.isNotBlank(orderCol) == true) {
        Boolean desc = Boolean.valueOf(req.getParameter("desc"));
        orderBy.add(new OrderBy(orderCol, desc));
    } else {
        orderBy.add(new OrderBy("modifiedAt", true));
    }
    String startRows = req.getParameter("startRow");
    String maxRows = req.getParameter("maxRow");
    int startRow = NumberUtils.toInt(startRows, 0);
    int maxRow = NumberUtils.toInt(maxRows, 30);
    boolean allAttrs = "true".equals(req.getParameter("allAttrs"));
    JsonArray ret = new JsonArray();
    Logging logging = LoggingServiceManager.get().getLogging();
    logging.selectLogs(start, end, level, logCategory, logMessage, logAttributes, startRow, maxRow, orderBy,
            allAttrs == false, (logEntry) -> {
                ret.add(LogJsonUtils.logEntryToJson(logging, logEntry, allAttrs));
            });
    sendResponse(resp, ret);
}