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:net.netheos.pcsapi.providers.googledrive.GoogleDrive.java

private CFile parseCFile(CPath parentPath, JSONObject json) {
    String dateStr = json.getString("modifiedDate");
    try {//  w w w.  java2  s  . c om
        CFile cFile;
        DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US);
        format.setLenient(false);

        if (dateStr.endsWith("Z")) { // ISO8601 syntax
            format.setTimeZone(TimeZone.getTimeZone("GMT"));
        }
        Date modified = format.parse(dateStr);
        if (MIME_TYPE_DIRECTORY.equals(json.getString("mimeType"))) {
            cFile = new CFolder(parentPath.add(json.getString("title")), modified, null); // metadata
        } else {
            long fileSize;
            if (json.has("fileSize")) {
                fileSize = json.getLong("fileSize");
            } else {
                // google apps files (application/vnd.google-apps.document, application/vnd.google-apps.spreadsheet, etc.)
                // do not publish any size (they can not be downloaded, only exported).
                fileSize = -1;
            }
            cFile = new CBlob(parentPath.add(json.getString("title")), fileSize, json.getString("mimeType"),
                    modified, null); // metadata
        }
        return cFile;

    } catch (ParseException ex) {
        throw new CStorageException("Can't parse date modified: " + dateStr + " (" + ex.getMessage() + ")", ex);
    }
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.manager.executionDegreesManagement.ExecutionDegreesManagementDispatchAction.java

public ActionForward editExecutionDegree(ActionMapping mapping, ActionForm actionForm,
        HttpServletRequest request, HttpServletResponse response) {

    final DynaActionForm form = (DynaActionForm) actionForm;
    final String executionDegreeID = (String) form.get("executionDegreeID");
    final String executionYearID = (String) form.get("executionYearID");
    final String campusID = (String) form.get("campusID");
    final String dateFormat = "dd/MM/yyyy";
    final Boolean temporaryExamMap = Boolean.valueOf((String) form.get("temporaryExamMap"));

    try {// ww w.  jav a  2  s. c o  m
        final Date periodLessonsFirstSemesterBegin = DateFormatUtil.parse(dateFormat,
                (String) form.get("periodLessonsFirstSemesterBegin"));
        final Date periodLessonsFirstSemesterEnd = DateFormatUtil.parse(dateFormat,
                (String) form.get("periodLessonsFirstSemesterEnd"));
        final Date periodExamsFirstSemesterBegin = DateFormatUtil.parse(dateFormat,
                (String) form.get("periodExamsFirstSemesterBegin"));
        final Date periodExamsFirstSemesterEnd = DateFormatUtil.parse(dateFormat,
                (String) form.get("periodExamsFirstSemesterEnd"));
        final Date periodLessonsSecondSemesterBegin = DateFormatUtil.parse(dateFormat,
                (String) form.get("periodLessonsSecondSemesterBegin"));
        final Date periodLessonsSecondSemesterEnd = DateFormatUtil.parse(dateFormat,
                (String) form.get("periodLessonsSecondSemesterEnd"));
        final Date periodExamsSecondSemesterBegin = DateFormatUtil.parse(dateFormat,
                (String) form.get("periodExamsSecondSemesterBegin"));
        final Date periodExamsSecondSemesterEnd = DateFormatUtil.parse(dateFormat,
                (String) form.get("periodExamsSecondSemesterEnd"));
        final Date periodExamsSpecialSeasonBegin = DateFormatUtil.parse(dateFormat,
                (String) form.get("periodExamsSpecialSeasonBegin"));
        final Date periodExamsSpecialSeasonEnd = DateFormatUtil.parse(dateFormat,
                (String) form.get("periodExamsSpecialSeasonEnd"));
        final Date periodGradeSubmissionNormalSeasonFirstSemesterEnd = DateFormatUtil.parse(dateFormat,
                (String) form.get("periodGradeSubmissionNormalSeasonFirstSemesterEnd"));
        final Date periodGradeSubmissionNormalSeasonSecondSemesterEnd = DateFormatUtil.parse(dateFormat,
                (String) form.get("periodGradeSubmissionNormalSeasonSecondSemesterEnd"));
        final Date periodGradeSubmissionSpecialSeasonEnd = DateFormatUtil.parse(dateFormat,
                (String) form.get("periodGradeSubmissionSpecialSeasonEnd"));

        EditExecutionDegree.run(executionDegreeID, executionYearID, campusID, !temporaryExamMap,
                periodLessonsFirstSemesterBegin, periodLessonsFirstSemesterEnd, periodExamsFirstSemesterBegin,
                periodExamsFirstSemesterEnd, periodLessonsSecondSemesterBegin, periodLessonsSecondSemesterEnd,
                periodExamsSecondSemesterBegin, periodExamsSecondSemesterEnd, periodExamsSpecialSeasonBegin,
                periodExamsSpecialSeasonEnd, periodGradeSubmissionNormalSeasonFirstSemesterEnd,
                periodGradeSubmissionNormalSeasonSecondSemesterEnd, periodGradeSubmissionSpecialSeasonEnd);

        return readExecutionDegrees(mapping, actionForm, request, response);

    } catch (final ParseException e) {
        addMessage(request, "error.executionDegrees.invalid.date.format");
    } catch (final NotAuthorizedException e) {
        addMessage(request, "error.notAuthorized");
        return readExecutionDegrees(mapping, actionForm, request, response);
    } catch (final FenixServiceException e) {
        addMessage(request, e.getMessage());
    } catch (final DomainException e) {
        addMessage(request, e.getMessage());
    }
    return prepareEditExecutionDegree(mapping, actionForm, request, response);
}

From source file:com.clustercontrol.calendar.dialog.CalendarDialog.java

/**
 * ??????/*ww  w.ja  va  2 s .c  o m*/
 *
 * @return ??
 *
 * @see
 */
private void createCalendarInfo() {

    this.inputData = new CalendarInfo();

    //ID?
    if (calIdText.getText().length() > 0) {
        inputData.setCalendarId(calIdText.getText());
    }
    m_log.trace("createCalendarInfo cal name = " + calNameText.getText());
    //???
    if (calNameText.getText().length() > 0 && !"".equals(calNameText.getText())) {
        m_log.trace("createCalendarInfo22 cal name = " + calNameText.getText());
        inputData.setCalendarName(calNameText.getText());
        m_log.trace("input cal name = " + inputData.getCalendarName());
    }
    //ID
    if (calRoleIdListComposite.getText().length() > 0) {
        inputData.setOwnerRoleId(calRoleIdListComposite.getText());
    }
    //?
    if (calDescription.getText().length() > 0) {
        inputData.setDescription(calDescription.getText());
    } else {
        inputData.setDescription("");
    }
    //?
    if (calTimeFromText.getText().length() > 0) {
        Date dateTimeFrom;
        try {
            dateTimeFrom = (TimezoneUtil.getSimpleDateFormat()).parse(calTimeFromText.getText());
            calTimeFrom = dateTimeFrom.getTime();
            inputData.setValidTimeFrom(calTimeFrom);
        } catch (ParseException e) {
            m_log.warn("createCalendarInfo : " + e.getMessage());
        }
    }
    //?
    if (calTimeToText.getText().length() > 0) {
        Date dateTimeTo;
        try {
            dateTimeTo = (TimezoneUtil.getSimpleDateFormat()).parse(calTimeToText.getText());
            calTimeTo = dateTimeTo.getTime();
            inputData.setValidTimeTo(calTimeTo);
        } catch (ParseException e) {
            m_log.warn("createCalendarInfo : " + e.getMessage());
        }
    }
    //?
    if (this.calDetailComposite.getDetailList() != null) {

        m_log.debug("Add CalendarDetailInfo : " + this.calDetailComposite.getDetailList().size());

        for (CalendarDetailInfo detailInfo : this.calDetailComposite.getDetailList()) {
            this.inputData.getCalendarDetailList().add(detailInfo);
        }
    }
}

From source file:es.tid.fiware.rss.dao.impl.test.DbeTransactionDaoImplTest.java

@Test
public void test20GetTransactionBySvcPrdtUserDate() {
    String txTransactionId = new String("1234");

    Long nuServiceId = new Long(1);
    String user = new String("tel:+34913329702");

    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd:hhmmss");
    String sdate = "2012-01-01:000000";
    // String sdate ="2012-01-01:000020"; it fail is seconds in database is 00
    Date date = null;//from ww  w  .  j  a  v  a  2 s .c o  m
    try {

        date = formatter.parse(sdate);

    } catch (ParseException ex) {

        ex.printStackTrace();
        Assert.fail("ParseException received: " + ex.getMessage());
    }

    List<DbeTransaction> listDbeTr = dbeTransactionDAO.getTransactionBySvcPrdtUserDate(nuServiceId, null, user,
            date);
    if (listDbeTr.size() >= 0) {
        DbeTransactionDaoImplTest.LOGGER.debug("looking result list data....");
        if (listDbeTr.size() == 0) {
            DbeTransactionDaoImplTest.LOGGER.debug("Obtained 0 data");
        } else {
            DbeTransactionDaoImplTest.LOGGER.debug("Obtained:" + listDbeTr.get(0).getTxTransactionId());
        }
    } else {
        DbeTransactionDaoImplTest.LOGGER.debug("Obtained nothing");

    }
    Assert.assertTrue("Transaction Id not equal",
            listDbeTr.get(0).getTxTransactionId().equals(txTransactionId));

}

From source file:com.glandorf1.joe.wsprnetviewer.app.sync.WsprNetViewerSyncAdapter.java

/**
 * Clean up and parse the raw timestamp from the html.
 * Since there may be multiple records with the same timestamp (the resolution is only 1 minute),
 * make sure there is a mechanism to distinguish each of them.
 *//*from  ww w  .ja  v a 2 s  .  c  om*/
public String parseTimestamp(String timestampStr) {
    SimpleDateFormat timestampFormatIn = new SimpleDateFormat(Utility.TIMESTAMP_FORMAT_WSPR);
    // TODO: getting parse exceptions-but maybe only in debug mode; SDF may not be suitable for
    //       use in static modules.
    //       Investigate using something like joda-time: http://www.joda.org/joda-time/
    try {
        Date inputTimestamp = timestampFormatIn.parse(timestampStr);
        inputTimestamp.setTime(inputTimestamp.getTime()); // + millisecondOffset); // can add a fake ms value to make timestamp unique
        String dbTimestamp = WsprNetContract.getDbTimestampString(inputTimestamp);
        return dbTimestamp;
    } catch (ParseException e) {
        Log.e(LOG_TAG, e.getMessage(), e);
        //e.printStackTrace();
        return timestampStr;
    }
}

From source file:org.apache.nifi.web.dao.impl.StandardProcessorDAO.java

private List<String> validateProposedConfiguration(final ProcessorNode processorNode,
        final ProcessorConfigDTO config) {
    List<String> validationErrors = new ArrayList<>();

    // validate settings
    if (isNotNull(config.getPenaltyDuration())) {
        Matcher penaltyMatcher = FormatUtils.TIME_DURATION_PATTERN.matcher(config.getPenaltyDuration());
        if (!penaltyMatcher.matches()) {
            validationErrors.add("Penalty duration is not a valid time duration (ie 30 sec, 5 min)");
        }/*from  w w w.  j ava  2 s  .  c  o  m*/
    }
    if (isNotNull(config.getYieldDuration())) {
        Matcher yieldMatcher = FormatUtils.TIME_DURATION_PATTERN.matcher(config.getYieldDuration());
        if (!yieldMatcher.matches()) {
            validationErrors.add("Yield duration is not a valid time duration (ie 30 sec, 5 min)");
        }
    }
    if (isNotNull(config.getBulletinLevel())) {
        try {
            LogLevel.valueOf(config.getBulletinLevel());
        } catch (IllegalArgumentException iae) {
            validationErrors.add(String.format("Bulletin level: Value must be one of [%s]",
                    StringUtils.join(LogLevel.values(), ", ")));
        }
    }
    if (isNotNull(config.getExecutionNode())) {
        try {
            ExecutionNode.valueOf(config.getExecutionNode());
        } catch (IllegalArgumentException iae) {
            validationErrors.add(String.format("Execution node: Value must be one of [%s]",
                    StringUtils.join(ExecutionNode.values(), ", ")));
        }
    }

    // get the current scheduling strategy
    SchedulingStrategy schedulingStrategy = processorNode.getSchedulingStrategy();

    // validate the new scheduling strategy if appropriate
    if (isNotNull(config.getSchedulingStrategy())) {
        try {
            // this will be the new scheduling strategy so use it
            schedulingStrategy = SchedulingStrategy.valueOf(config.getSchedulingStrategy());
        } catch (IllegalArgumentException iae) {
            validationErrors.add(String.format("Scheduling strategy: Value must be one of [%s]",
                    StringUtils.join(SchedulingStrategy.values(), ", ")));
        }
    }

    // validate the concurrent tasks based on the scheduling strategy
    if (isNotNull(config.getConcurrentlySchedulableTaskCount())) {
        switch (schedulingStrategy) {
        case TIMER_DRIVEN:
        case PRIMARY_NODE_ONLY:
            if (config.getConcurrentlySchedulableTaskCount() <= 0) {
                validationErrors.add("Concurrent tasks must be greater than 0.");
            }
            break;
        case EVENT_DRIVEN:
            if (config.getConcurrentlySchedulableTaskCount() < 0) {
                validationErrors.add("Concurrent tasks must be greater or equal to 0.");
            }
            break;
        }
    }

    // validate the scheduling period based on the scheduling strategy
    if (isNotNull(config.getSchedulingPeriod())) {
        switch (schedulingStrategy) {
        case TIMER_DRIVEN:
        case PRIMARY_NODE_ONLY:
            final Matcher schedulingMatcher = FormatUtils.TIME_DURATION_PATTERN
                    .matcher(config.getSchedulingPeriod());
            if (!schedulingMatcher.matches()) {
                validationErrors.add("Scheduling period is not a valid time duration (ie 30 sec, 5 min)");
            }
            break;
        case CRON_DRIVEN:
            try {
                new CronExpression(config.getSchedulingPeriod());
            } catch (final ParseException pe) {
                throw new IllegalArgumentException(
                        String.format("Scheduling Period '%s' is not a valid cron expression: %s",
                                config.getSchedulingPeriod(), pe.getMessage()));
            } catch (final Exception e) {
                throw new IllegalArgumentException(
                        "Scheduling Period is not a valid cron expression: " + config.getSchedulingPeriod());
            }
            break;
        }
    }

    final Set<String> autoTerminatedRelationships = config.getAutoTerminatedRelationships();
    if (isNotNull(autoTerminatedRelationships)) {
        for (final String relationshipName : autoTerminatedRelationships) {
            final Relationship relationship = new Relationship.Builder().name(relationshipName).build();
            final Set<Connection> connections = processorNode.getConnections(relationship);
            if (isNotNull(connections) && !connections.isEmpty()) {
                validationErrors.add("Cannot automatically terminate '" + relationshipName
                        + "' relationship because a Connection already exists with this relationship");
            }
        }
    }

    return validationErrors;
}

From source file:org.easy.test.criteria.CriteriaProcessorTest.java

/**
 * //from ww  w.  j av a  2s.  co  m
 * select * from course where course.last_update_date_time between ? and ?
 */
@Test
public void testBetweenDates() {
    Date thatDate = null;

    try {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        thatDate = simpleDateFormat.parse("2011-01-02 00:00:00");
    } catch (ParseException e) {
        log.error(e);
        fail(e.getMessage());
    }

    Date toDate = new Date(System.currentTimeMillis());

    CriteriaComposer<Course> criteria = CriteriaComposer.from(Course.class);
    criteria.where(Course_.lastUpdateDateTime, ComparisonOperator.BETWEEN, thatDate, toDate);

    List<Course> result = criteriaProcessor.findAllEntity(criteria, true, null);

    assertNotNull(result);
    assertEquals(2, result.size());
    assertEquals("course2", result.get(0).getName());
}

From source file:com.payu.sdk.util.UtilTest.java

/**
 * The address adapter test// w  ww . j a  va2 s  .  c  om
 */
@Test
public void addressAdapterTest() {

    AddressAdapter adapter = new AddressAdapter();

    Address add;
    AddressV4 addV4 = null;

    try {
        add = adapter.unmarshal(addV4);
        Assert.assertNull(add);
    } catch (ParseException ex) {
        LoggerUtil.error(ex.getMessage(), ex);
        Assert.fail(ex.getMessage());
    }

    addV4 = new AddressV4();

    try {
        add = adapter.unmarshal(addV4);
        Assert.assertNotNull(add);
    } catch (ParseException ex) {
        LoggerUtil.error(ex.getMessage(), ex);
        Assert.fail(ex.getMessage());
    }

}

From source file:org.easy.test.criteria.CriteriaProcessorTest.java

/**
 * OrderBy/*from  w  w w .  j av  a2s  .  com*/
 * 
 * select * from course
 * where course.last_update_date_time between ? and ?
 * order by course.name desc
 */
@Test
public void testOrderBy() {
    Date thatDate = null;

    try {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        thatDate = simpleDateFormat.parse("2011-01-02 00:00:00");
    } catch (ParseException e) {
        log.error(e);
        fail(e.getMessage());
    }

    Date toDate = new Date(System.currentTimeMillis());

    CriteriaComposer<Course> criteria = CriteriaComposer.from(Course.class);
    criteria.where(Course_.lastUpdateDateTime, ComparisonOperator.BETWEEN, thatDate, toDate);
    criteria.orderBy(Course_.name, false, 1);

    List<Course> result = criteriaProcessor.findAllEntity(criteria, true, null);

    assertNotNull(result);
    assertEquals(2, result.size());
    assertEquals("course3", result.get(0).getName());
}

From source file:org.kuali.coeus.common.budget.impl.calculator.SalaryCalculator.java

private List<BudgetRate> createAnnualInflationRates(BudgetPerson budgetPerson) {
    List<BudgetRate> budgetRates = new ArrayList<BudgetRate>();
    List<BudgetRate> inflationRatesList = filterInflationRates(budgetPerson.getEffectiveDate(), this.endDate);
    if (inflationRatesList.isEmpty()) {
        return budgetRates;
    }//from  w  w w  . ja v  a  2 s.co m
    BudgetRate inflationRate = getInflationRateToBeApplied(inflationRatesList,
            budgetPerson.getSalaryAnniversaryDate());
    BudgetRate budgetRate = null;
    if (inflationRate != null) {
        budgetRate = (BudgetRate) ObjectUtils.deepCopy(inflationRate);
        if (!budgetPerson.getSalaryAnniversaryDate().before(budgetPerson.getEffectiveDate())) {
            budgetRate.setStartDate(budgetPerson.getSalaryAnniversaryDate());
        }
        budgetRates.add(budgetRate);
    }
    Calendar salaryDateCalendar = dateTimeService.getCalendar(budgetPerson.getSalaryAnniversaryDate());
    int startYear = salaryDateCalendar.get(Calendar.YEAR);
    Calendar endCalendar = dateTimeService.getCalendar(endDate);
    int endYear = endCalendar.get(Calendar.YEAR);
    if (startYear != endYear) {
        while (salaryDateCalendar.get(Calendar.YEAR) <= endYear) {
            salaryDateCalendar.add(Calendar.YEAR, 1);
            Date nextInflationDate = salaryDateCalendar.getTime();
            if (nextInflationDate.after(endDate)) {
                break;
            }
            BudgetRate inflationRateToBeApplied = getInflationRateToBeApplied(inflationRatesList,
                    nextInflationDate);
            if (inflationRateToBeApplied != null) {
                BudgetRate nextBudgetRate = (BudgetRate) ObjectUtils.deepCopy(inflationRateToBeApplied);
                try {
                    nextBudgetRate.setStartDate(
                            dateTimeService.convertToSqlDate(dateTimeService.toDateString(nextInflationDate)));
                    budgetRates.add(nextBudgetRate);
                } catch (ParseException e) {
                    LOG.error(e.getMessage(), e);
                }
            }
        }
    }
    return budgetRates;
}