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:com.datastax.loader.CqlDelimParser.java

@SuppressWarnings("unchecked")
public List<Object> parseJson(String line) {
    JSONObject jsonObject = null;//from  w  w w  .j a v  a2s  .c  o  m
    try {
        jsonObject = (JSONObject) jsonParser.parse(line);
    } catch (org.json.simple.parser.ParseException e) {
        System.err.println(String.format("Invalid format in input %d: %s", line, e.getMessage()));
        return null;
    }
    String[] row = new String[columnNames.size()];
    Set<String> fields = (Set<String>) jsonObject.keySet();
    for (int i = 0; i < columnNames.size(); i++) {
        String s = columnNames.get(i);
        Object o = jsonObject.get(s);
        if (null != o)
            row[i] = o.toString();
        else
            row[i] = null;
        fields.remove(s);
    }
    if (0 != fields.size()) {
        for (String f : fields) {
            System.err.println("Unknown JSON field " + f);
        }
        return null;
    }
    return parse(row);
}

From source file:fr.cph.stock.external.YahooExternalDataAccess.java

@Override
public final List<Index> getIndexDataHistory(final String yahooId, final Date from, final Date to)
        throws YahooException {
    DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
    String startDate = formatter.format(from);
    Calendar cal = Calendar.getInstance();
    String endDate;//from   www.  jav  a  2 s.  c  o  m
    if (to == null) {
        endDate = formatter.format(cal.getTime());
    } else {
        endDate = formatter.format(to);
    }
    List<Index> indexes = new ArrayList<Index>();
    String request = "select * from yahoo.finance.historicaldata where symbol = \"" + yahooId
            + "\" and startDate = \"" + startDate + "\" and endDate = \"" + endDate + "\"";
    Yahoo yahoo = new Yahoo(request);
    JSONObject json = yahoo.getJSONObject();
    JSONArray jsonResults = getJSONArrayFromJSONObject(json);
    for (int j = 0; j < jsonResults.size(); j++) {
        JSONObject jsonIndex = jsonResults.getJSONObject(j);
        Index index = new Index();
        index.setValue(jsonIndex.getDouble("Close"));

        Date date;
        try {
            date = formatter.parse(jsonIndex.optString("Date"));
        } catch (ParseException e) {
            throw new YahooException(e.getMessage(), e);
        }
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        index.setDate(calendar.getTime());
        index.setYahooId(yahooId);
        indexes.add(index);
    }
    return indexes;
}

From source file:de.netsat.orekit.util.ZipJarCrawler.java

/** {@inheritDoc} */
public boolean feed(final Pattern supported, final DataLoader visitor) throws OrekitException {

    try {//  www.java  2 s.  c  o  m

        // open the raw data stream
        Archive archive = null;
        ;
        try {
            if (file != null) {
                archive = new Archive(new FileInputStream(file));
            } else if (resource != null) {
                archive = new Archive(classLoader.getResourceAsStream(resource));
            } else {
                archive = new Archive(url.openConnection().getInputStream());
            }

            return feed(name, supported, visitor, archive);

        } finally {
            if (archive != null) {
                archive.close();
            }
        }

    } catch (IOException ioe) {
        throw new OrekitException(ioe, new DummyLocalizable(ioe.getMessage()));
    } catch (ParseException pe) {
        throw new OrekitException(pe, new DummyLocalizable(pe.getMessage()));
    }

}

From source file:ch.cyberduck.core.dropbox.DropboxPath.java

@Override
public AttributedList<Path> list(final AttributedList<Path> children) {
    if (this.attributes().isDirectory()) {
        try {/* w ww .j a va  2  s  . c o  m*/
            this.getSession().check();
            this.getSession().message(MessageFormat
                    .format(Locale.localizedString("Listing directory {0}", "Status"), this.getName()));

            for (ListEntryResponse entry : this.getSession().getClient().list(this.getAbsolute())
                    .getContents()) {
                final Path file = PathFactory.createPath(this.getSession(), entry.getPath(),
                        entry.isDirectory() ? Path.DIRECTORY_TYPE : Path.FILE_TYPE);
                file.setParent(this);
                file.attributes().setSize(entry.getLength());
                file.attributes().setChecksum(entry.getHash());
                try {
                    file.attributes()
                            .setModificationDate(SIMPLE_DATE_FORMAT.parse(entry.getModified()).getTime());
                } catch (ParseException e) {
                    log.warn("Failed parsing modification date:" + e.getMessage());
                }
                file.attributes().setRevision(entry.getRevision());
                file.attributes().setChecksum(entry.getHash());
                children.add(file);
            }
            this.getSession().setWorkdir(this);
        } catch (IOException e) {
            log.warn("Listing directory failed:" + e.getMessage());
            children.attributes().setReadable(false);
            if (this.cache().isEmpty()) {
                this.error(e.getMessage(), e);
            }
        }
    }
    return children;
}

From source file:com.all.client.model.TimeComparator.java

@Override
public int compare(String o1, String o2) {
    try {/*from   w  ww . j  a va 2s .c  o m*/
        Date one = parseDate(o1);
        Date two = parseDate(o2);
        return one.compareTo(two);
    } catch (ParseException e) {
        log.error(e.getMessage(), e);
    }
    return 0;
}

From source file:com.wso2telco.proxy.entity.ServerInitiatedServiceEndpoints.java

private JWSObject processJWE(String message) throws ParseException {
    JWSObject jwsObject;/*w  w  w  .j  av a 2  s .  c o m*/
    try {
        jwsObject = JWSObject.parse(message);
        if (log.isDebugEnabled()) {
            log.debug("JWS object successfully parsed");
        }
    } catch (java.text.ParseException e) {
        log.error("Couldn't parse JWS object: " + e.getMessage());
        throw e;
    }
    return jwsObject;
}

From source file:edu.lternet.pasta.portal.search.BrowseTerm.java

/**
 * Generates an XML string for storing this browse term in the browse cache
 * on disk as a <term> element.// w ww. ja  v a  2 s. c  o m
 */
String toXML() {
    String cacheString = null;
    String searchResults = readSearchResults();
    StringBuffer stringBuffer = new StringBuffer("");
    int indent = calculateIndent();

    for (int i = 0; i < indent; i++) {
        stringBuffer.append(" ");
    }
    stringBuffer.append(String.format("<term level='%d' hasMoreDown='0'>\n", this.level));
    for (int i = 0; i < indent + 4; i++) {
        stringBuffer.append(" ");
    }
    stringBuffer.append("<value>" + value + "</value>\n");

    if (searchResults != null) {
        /* Count the number of matching documents */
        this.matchCount = 0;

        try {
            ResultSetUtility resultSetUtility = new ResultSetUtility(searchResults, Search.DEFAULT_SORT);
            Integer numFound = resultSetUtility.getNumFound();
            this.matchCount = numFound;
        } catch (ParseException e) {
            logger.error(String.format("Error parsing search results: %s", e.getMessage()));
            e.printStackTrace();
        }

        for (int i = 0; i < indent + 4; i++) {
            stringBuffer.append(" ");
        }

        stringBuffer.append(String.format("<matchCount>%d</matchCount>\n", this.matchCount));
    }

    for (int i = 0; i < indent; i++) {
        stringBuffer.append(" ");
    }
    stringBuffer.append("</term>\n");

    cacheString = stringBuffer.toString();
    return cacheString;
}

From source file:org.egov.collection.service.CollectionReportService.java

public SQLQuery getOnlinePaymentReportData(final String districtName, final String ulbName,
        final String fromDate, final String toDate, final String transactionId) {
    final SimpleDateFormat dateFormatter = new SimpleDateFormat("dd/MM/yyyy");
    final StringBuilder queryStr = new StringBuilder(500);
    queryStr.append("select * from ").append(environmentSettings.statewideSchemaName())
            .append(".onlinepayment_view opv where 1=1");

    if (StringUtils.isNotBlank(districtName))
        queryStr.append(" and opv.districtName=:districtName ");
    if (StringUtils.isNotBlank(ulbName))
        queryStr.append(" and opv.ulbName=:ulbName ");
    if (StringUtils.isNotBlank(fromDate))
        queryStr.append(" and opv.transactiondate>=:fromDate ");
    if (StringUtils.isNotBlank(toDate))
        queryStr.append(" and opv.transactiondate<=:toDate ");
    if (StringUtils.isNotBlank(transactionId))
        queryStr.append(" and opv.transactionnumber like :transactionnumber ");
    queryStr.append(" order by receiptdate desc ");

    final SQLQuery query = getCurrentSession().createSQLQuery(queryStr.toString());

    if (StringUtils.isNotBlank(districtName))
        query.setString("districtName", districtName);
    if (StringUtils.isNotBlank(ulbName))
        query.setString("ulbName", ulbName);
    try {//from  w w w  .  j  a v a2s .  c o  m
        if (StringUtils.isNotBlank(fromDate))
            query.setDate("fromDate", dateFormatter.parse(fromDate));
        if (StringUtils.isNotBlank(toDate))
            query.setDate("toDate", dateFormatter.parse(toDate));
    } catch (final ParseException e) {
        LOGGER.error("Exception parsing Date" + e.getMessage());
    }
    if (StringUtils.isNotBlank(transactionId))
        query.setString("transactionnumber", "%" + transactionId + "%");
    queryStr.append(" order by opv.receiptdate desc");
    query.setResultTransformer(new AliasToBeanResultTransformer(OnlinePaymentResult.class));
    return query;
}

From source file:com.sunrun.crportal.util.CRPortalUtil.java

public static Calendar setNewCalendar(Calendar oldCalendar, TimeZone tz) {

    LOG.debug("* ---------------------------------------------------------- *");
    LOG.debug("* setNewCalendar - Entering                                  *");
    LOG.debug("* ---------------------------------------------------------- *");

    SimpleDateFormat sdf = new SimpleDateFormat(df);
    //sdf.setTimeZone(tz);
    LOG.debug("   setNewCalendar - oldCalendar = " + sdf.format(oldCalendar.getTimeInMillis()));
    LOG.debug("   setNewCalendar - TimeZone    = " + tz.getID());

    Calendar newCalendar = null;//  w  ww.  j  a  va 2s.  com

    DateFormat dfm;
    int intDay;
    int intMonth;
    int intYear;
    Date dtRightNow = null;
    String strRightNow;

    intDay = oldCalendar.get(Calendar.DAY_OF_MONTH);
    intMonth = oldCalendar.get(Calendar.MONTH);
    intYear = oldCalendar.get(Calendar.YEAR);

    strRightNow = "";
    strRightNow += intYear;
    strRightNow += "-";
    strRightNow += intMonth + 1;
    strRightNow += "-";
    strRightNow += intDay;
    LOG.debug("   setCalendar - strRightNow = " + strRightNow);
    try {
        dfm = new SimpleDateFormat("yyyy-MM-dd");
        //dfm.setTimeZone(tz);
        dtRightNow = dfm.parse(strRightNow);
        newCalendar = Calendar.getInstance(tz);
        newCalendar.setTime(dtRightNow);
        LOG.debug("   setNewCalendar - newCalendar    = " + sdf.format(newCalendar.getTimeInMillis()));
        LOG.debug("   setNewCalendar - newCalendar TZ = " + newCalendar.getTimeZone().getID());
    } catch (java.text.ParseException e) {
        LOG.warn(e.getMessage());
        LOG.debug("   setNewCalendar - defaultFromDate = null");
    }

    LOG.debug("* ---------------------------------------------------------- *");
    LOG.debug("* setNewCalendar - Exiting                                   *");
    LOG.debug("* ---------------------------------------------------------- *");
    return newCalendar;
}

From source file:edu.duke.cabig.c3pr.web.admin.CreateNotificationController.java

private Trigger generateTriggerForReportBasedEvents(PlannedNotification pn) {
    Trigger t = null;/* www.  j  ava2s.  c  o  m*/
    try {
        if (pn.getFrequency().equals(NotificationFrequencyEnum.WEEKLY)) {
            //all ids are of the form  "TW:Event-Freq-id:"
            //every Friday at 12:00pm
            t = new CronTrigger("TW: " + getUniqueIdForTrigger(pn), "TGW" + getUniqueIdForTrigger(pn), WEEKLY);
        }
        if (pn.getFrequency().equals(NotificationFrequencyEnum.MONTHLY)) {
            //every last day of month at 12:00pm
            t = new CronTrigger("TM" + getUniqueIdForTrigger(pn), "TGM" + getUniqueIdForTrigger(pn), MONTHLY);
        }
        if (pn.getFrequency().equals(NotificationFrequencyEnum.ANNUAL)) {
            //every last day December at 12:00pm
            t = new CronTrigger("TA" + getUniqueIdForTrigger(pn), "TGA" + getUniqueIdForTrigger(pn), ANNUAL);
        }
    } catch (ParseException e) {
        log.error(e.getMessage());
    }
    return t;
}