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:eu.optimis.mi.monitoring_manager.resources.MonitorManagerQueryResource.java

@GET
@Path("date/metric/{metricName}/{resourceType}/{id}/{from}.{to}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public MonitoringResourceDatasets getDateIDMetricLevelResource(@PathParam("metricName") String metricName,
        @PathParam("resourceType") String resourceType, @PathParam("id") String id,
        @PathParam("from") String from, @PathParam("to") String to) {

    SimpleDateFormat sdf = new SimpleDateFormat(dateformat);
    java.util.Date dfrom = null;/*from w w  w  .j a v a 2  s  . c  o m*/
    java.util.Date dto = null;
    try {
        dfrom = sdf.parse(from);
        dto = sdf.parse(to);
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    eu.optimis.mi.monitoring_manager.db.Connection conn;
    java.sql.Connection dbconn;
    try {
        conn = ConnectionPool.getFreeConnection();
        dbconn = conn.getDBConnection(DB_TABLE_URL, DB_DRIVER, DB_USERNAME, DB_PASSWORD);
    } catch (Exception e) {
        logger.error("DB info:" + DB_TABLE_URL + " | " + DB_DRIVER + " | " + DB_USERNAME + " | " + DB_PASSWORD);
        logger.error("MonitoringManager DB connection error: " + e.getMessage());
        return new MonitoringResourceDatasets();
    }
    return GuiQuery.getDate_Metric_tid(dbconn, metricName, resourceType, id, dfrom, dto);
}

From source file:eu.optimis.mi.monitoring_manager.resources.MonitorManagerQueryResource.java

@GET
@Path("date/metric/{metricName}/{resourceType}/{from}.{to}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public MonitoringResourceDatasets getDateTypeMetricLevelResource(@PathParam("metricName") String metricName,
        @PathParam("resourceType") String resourceType, @PathParam("from") String from,
        @PathParam("to") String to) {

    SimpleDateFormat sdf = new SimpleDateFormat(dateformat);
    java.util.Date dfrom = null;/*from  w  w  w  . j  a  v a 2s.  com*/
    java.util.Date dto = null;
    try {
        dfrom = sdf.parse(from);
        dto = sdf.parse(to);
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    eu.optimis.mi.monitoring_manager.db.Connection conn;
    java.sql.Connection dbconn;
    try {
        conn = ConnectionPool.getFreeConnection();
        dbconn = conn.getDBConnection(DB_TABLE_URL, DB_DRIVER, DB_USERNAME, DB_PASSWORD);
    } catch (Exception e) {
        logger.error("DB info:" + DB_TABLE_URL + " | " + DB_DRIVER + " | " + DB_USERNAME + " | " + DB_PASSWORD);
        logger.error("MonitoringManager DB connection error: " + e.getMessage());
        return new MonitoringResourceDatasets();
    }
    logger.info("DB_TABLE_URL:" + DB_TABLE_URL);
    return DateTypeLevelQuery.getResource_type_mname(dbconn, resourceType, metricName, dfrom, dto);
}

From source file:com.amalto.workbench.editors.DataClusterComposite.java

private long parseTime(String timeStr) {
    try {// w  w w.j  a v  a2  s  .co m
        Date d = sdf.parse(timeStr);
        long time = d.getTime();
        return time;
    } catch (ParseException pe) {
        log.error(pe.getMessage(), pe);
    }

    return -1L;
}

From source file:net.solarnetwork.node.settings.ca.CASettingsService.java

@Override
public Collection<SettingsBackup> getAvailableBackups() {
    final File dir = new File(backupDestinationPath);
    File[] files = dir.listFiles(new RegexFileFilter(BACKUP_FILENAME_PATTERN));
    if (files == null || files.length == 0) {
        return Collections.emptyList();
    }//  w  ww.j  a v  a2  s .co m
    Arrays.sort(files, new FilenameReverseComparator());
    List<SettingsBackup> list = new ArrayList<SettingsBackup>(files.length);
    SimpleDateFormat sdf = new SimpleDateFormat(BACKUP_DATE_FORMAT);
    for (File f : files) {
        Matcher m = BACKUP_FILENAME_PATTERN.matcher(f.getName());
        if (m.matches()) {
            String dateStr = m.group(1);
            try {
                list.add(new SettingsBackup(dateStr, sdf.parse(dateStr)));
            } catch (ParseException e) {
                log.warn("Unable to parse backup file date from filename {}: {}", f.getName(), e.getMessage());
            }
        }
    }
    return list;
}

From source file:ch.cyberduck.core.ftp.FTPPath.java

/**
 * Parse the timestamp using the MTDM format
 *
 * @param timestamp Date string//w  ww .j  a  va 2 s .com
 * @return Milliseconds
 */
public long parseTimestamp(final String timestamp) {
    if (null == timestamp) {
        return -1;
    }
    try {
        Date parsed = new MDTMSecondsDateFormatter().parse(timestamp);
        return parsed.getTime();
    } catch (ParseException e) {
        log.warn("Failed to parse timestamp:" + e.getMessage());
        try {
            Date parsed = new MDTMMillisecondsDateFormatter().parse(timestamp);
            return parsed.getTime();
        } catch (ParseException f) {
            log.warn("Failed to parse timestamp:" + f.getMessage());
        }
    }
    log.error(String.format("Failed to parse timestamp %s", timestamp));
    return -1;
}

From source file:org.egov.egf.web.actions.voucher.BaseVoucherAction.java

/**
 *
 *///  w  ww.  ja  v  a2  s  .c  o  m
protected void loadDefalutDates() {
    final Date currDate = new Date();
    final SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
    try {
        voucherHeader.setVoucherDate(sdf.parse(sdf.format(currDate)));
    } catch (final ParseException e) {
        LOGGER.error("Inside loadDefalutDates" + e.getMessage(), e);
        throw new ValidationException(Arrays
                .asList(new ValidationError("Exception while formatting voucher date", "Transaction failed")));
    }
}

From source file:net.solarnetwork.node.settings.ca.CASettingsService.java

@Override
public SettingsBackup backupSettings() {
    final Date mrd = settingDao.getMostRecentModificationDate();
    final SimpleDateFormat sdf = new SimpleDateFormat(BACKUP_DATE_FORMAT);
    final String lastBackupDateStr = settingDao.getSetting(SETTING_LAST_BACKUP_DATE);
    final Date lastBackupDate;
    try {//from   w  w w  .jav a2 s . c  om
        lastBackupDate = (lastBackupDateStr == null ? null : sdf.parse(lastBackupDateStr));
    } catch (ParseException e) {
        throw new RuntimeException("Unable to parse backup last date: " + e.getMessage());
    }
    if (mrd == null || (lastBackupDate != null && lastBackupDate.after(mrd))) {
        log.debug("Settings unchanged since last backup on {}", lastBackupDateStr);
        return null;
    }
    final Date backupDate = new Date();
    final String backupDateKey = sdf.format(backupDate);
    final File dir = new File(backupDestinationPath);
    if (!dir.exists()) {
        dir.mkdirs();
    }
    final File f = new File(dir, BACKUP_FILENAME_PREFIX + backupDateKey + '.' + BACKUP_FILENAME_EXT);
    log.info("Backing up settings to {}", f.getPath());
    Writer writer = null;
    try {
        writer = new BufferedWriter(new FileWriter(f));
        exportSettingsCSV(writer);
        settingDao.storeSetting(new Setting(SETTING_LAST_BACKUP_DATE, null, backupDateKey,
                EnumSet.of(SettingFlag.IgnoreModificationDate)));
    } catch (IOException e) {
        log.error("Unable to create settings backup {}: {}", f.getPath(), e.getMessage());
    } finally {
        try {
            writer.flush();
            writer.close();
        } catch (IOException e) {
            // ignore
        }
    }

    // clean out older backups
    File[] files = dir.listFiles(new RegexFileFilter(BACKUP_FILENAME_PATTERN));
    if (files != null && files.length > backupMaxCount) {
        // sort array 
        Arrays.sort(files, new FilenameReverseComparator());
        for (int i = backupMaxCount; i < files.length; i++) {
            if (!files[i].delete()) {
                log.warn("Unable to delete old settings backup file {}", files[i]);
            }
        }
    }
    return new SettingsBackup(backupDateKey, backupDate);
}

From source file:com.streamreduce.util.GitHubClient.java

/**
 * Returns a Date object for the value represented in the JSON object's 'created_at' property.
 *
 * @param jsonObject the JSON object to parse
 *
 * @return the date value of the 'created_at' property of the JSON object or null otherwise
 *///from w  ww . j ava  2s.  com
private Date getCreatedDate(JSONObject jsonObject) {
    String rawActivityDate = (jsonObject.has("created_at") ? jsonObject.getString("created_at") : null);
    Date activityDate = null;

    if (rawActivityDate != null) {
        // Example date: 2011-09-06T17:26:27Z
        try {
            activityDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").parse(rawActivityDate);
        } catch (ParseException e) {
            LOGGER.error("Unable to parse the date (" + rawActivityDate + "): " + e.getMessage());
            e.printStackTrace();
        }
    }

    return activityDate;
}

From source file:com.buffalokiwi.aerodrome.jet.products.JetAPIProduct.java

/**
 * Retrieve product inventory by sku.//  w ww  .  ja v a 2 s.co m
 * The inventory returned from this endpoint represents the number in the 
 * feed, not the quantity that is currently sellable on Jet.com
 * 
 * @param sku Product sku
 * @return api response 
 * @throws APIException
 * @throws JetException 
 */
@Override
public ProductInventoryRec getProductInventory(final String sku) throws APIException, JetException {
    try {
        return ProductInventoryRec.fromJSON(sendGetProductInventory(sku).getJsonObject());
    } catch (ParseException e) {
        APILog.error(LOG, "Failed to parse Jet Fulfillment Node lastUpdate Date:", e.getMessage());
        throw new JetException("getProductPrice result was successful, but "
                + "Fulfillment node had an invalid lastUpdate date", e);
    }
}

From source file:org.apache.directory.fortress.core.AuditMgrConsole.java

/**
 *
 * @param list/*from  ww w .  ja v a 2  s. c o m*/
 */
void printAuthNReport(List<Bind> list) {
    if (list != null && list.size() > 0) {
        int ctr = 0;
        for (Bind aBind : list) {
            /*
            public class Bind
            private String createTimestamp;
            private String creatorsName;
            private String entryCSN;
            private String entryDN;
            private String entryUUID;
            private String hasSubordinates;
            private String modifiersName;
            private String modifyTimestamp;
            private String objectClass;
            private String reqAuthzID;
            private String reqControls;
            private String reqDN;
            private String reqEnd;
            private String reqMethod;
            private String reqResult;
            private String reqSession;
            private String reqStart;
            private String reqType;
            private String reqVersion;
            private String structuralObjectClass;
            */
            System.out.println("AUTHENTICATION AUDIT RECORD " + ctr++);
            System.out.println("***************************************");
            System.out.println("    UserId        " + AuditUtil.getAuthZId(aBind.getReqDN()));
            Date aDate = null;
            try {
                aDate = TUtil.decodeGeneralizedTime(aBind.getReqEnd());
            } catch (ParseException pe) {
                System.out.println("    Bind Time     " + "ParseException=" + pe.getMessage());
            }
            if (aDate != null) {
                SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
                String formattedDate = formatter.format(aDate);
                System.out.println("    Bind Time     " + formattedDate);
            }
            System.out.println("    AuthN Type    " + aBind.getReqMethod());
            System.out.println("    Success?      " + aBind.getReqResult().equals("0"));
            System.out.println("    Session       " + aBind.getReqSession());
            System.out.println("    Type          " + aBind.getReqType());
            System.out.println("    Version       " + aBind.getReqVersion());
            System.out.println();
            System.out.println();
        }
    } else {
        System.out.println("no authN's found");
    }
}