java.text.ParseException.getMessage()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(112)

本文整理了Java中java.text.ParseException.getMessage()方法的一些代码示例,展示了ParseException.getMessage()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ParseException.getMessage()方法的具体详情如下:
包路径:java.text.ParseException
类名称:ParseException
方法名:getMessage

ParseException.getMessage介绍

暂无

代码示例

代码示例来源:origin: apache/incubator-dubbo

@Override
  public Object decode(Object jv) throws IOException {
    if (jv instanceof String) {
      try {
        return new SimpleDateFormat(DATE_FORMAT).parse((String) jv);
      } catch (ParseException e) {
        throw new IllegalArgumentException(e.getMessage(), e);
      }
    }
    if (jv instanceof Number) {
      return new Date(((Number) jv).longValue());
    }
    return (Date) null;
  }
};

代码示例来源:origin: spring-projects/spring-framework

/**
 * Parse the Date from the given text, using the specified DateFormat.
 */
@Override
public void setAsText(@Nullable String text) throws IllegalArgumentException {
  if (this.allowEmpty && !StringUtils.hasText(text)) {
    // Treat empty String as null value.
    setValue(null);
  }
  else if (text != null && this.exactDateLength >= 0 && text.length() != this.exactDateLength) {
    throw new IllegalArgumentException(
        "Could not parse date: it is not exactly" + this.exactDateLength + "characters long");
  }
  else {
    try {
      setValue(this.dateFormat.parse(text));
    }
    catch (ParseException ex) {
      throw new IllegalArgumentException("Could not parse date: " + ex.getMessage(), ex);
    }
  }
}

代码示例来源:origin: knowm/XChange

private static Date adaptDate(String date) {
 DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 Date result;
 try {
  result = format.parse(date);
 } catch (ParseException e) {
  throw new ExchangeException("Date/time parse error: " + e.getMessage());
 }
 return result;
}

代码示例来源:origin: org.apache.maven/maven-plugin-api

DateFormat dateParser = new java.text.SimpleDateFormat( effectiveDateFormat, java.util.Locale.US );
return dateParser.parse( s );
throw new XmlPullParserException( e.getMessage(), parser, e );

代码示例来源:origin: apache/incubator-dubbo

@Override
  public Object decode(Object jv) throws IOException {
    if (jv instanceof String) {
      try {
        return new SimpleDateFormat(DATE_FORMAT).parse((String) jv);
      } catch (ParseException e) {
        throw new IllegalArgumentException(e.getMessage(), e);
      }
    }
    if (jv instanceof Number) {
      return new Date(((Number) jv).longValue());
    }
    return (Date) null;
  }
};

代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl

@Override
public Date parseDate(String dateStr)
  throws IllegalArgumentException
{
  try {
    return getDateFormat().parse(dateStr);
  } catch (ParseException pex) {
    throw new IllegalArgumentException(pex.getMessage());
  }
}

代码示例来源:origin: apache/maven

DateFormat dateParser = new java.text.SimpleDateFormat( effectiveDateFormat, java.util.Locale.US );
return dateParser.parse( s );
throw new XmlPullParserException( e.getMessage(), parser, e );

代码示例来源:origin: apache/incubator-gobblin

synchronized private static long toEpoch(String dateTime) {
 Date date = null;
 final SimpleDateFormat inputFormat = new SimpleDateFormat(INPUTFORMAT);
 try {
  date = inputFormat.parse(dateTime);
 } catch (ParseException e) {
  throw new RuntimeException(e.getMessage(), e);
 }
 return date.getTime();
}

代码示例来源:origin: spring-projects/spring-batch

private Date parseDate(String readAndTrim, DateFormat dateFormat) {
  try {
    return dateFormat.parse(readAndTrim);
  }
  catch (ParseException e) {
    String pattern;
    if (dateFormat instanceof SimpleDateFormat) {
      pattern = ((SimpleDateFormat) dateFormat).toPattern();
    }
    else {
      pattern = dateFormat.toString();
    }
    throw new IllegalArgumentException(e.getMessage() + ", format: [" + pattern + "]");
  }
}

代码示例来源:origin: apache/maven

DateFormat dateParser = new java.text.SimpleDateFormat( effectiveDateFormat, java.util.Locale.US );
return dateParser.parse( s );
throw new XmlPullParserException( e.getMessage(), parser, e );

代码示例来源:origin: wildfly/wildfly

/** Convert the stored date-string from database back to Date */
private Date stringAsSchedulerDate(final String date, final String timerId) {
  if (date == null) {
    return null;
  }
  try {
    return new SimpleDateFormat(SCHEDULER_DATE_FORMAT).parse(date);
  } catch (ParseException e) {
    EjbLogger.EJB3_TIMER_LOGGER.scheduleExpressionDateFromTimerPersistenceInvalid(timerId, e.getMessage());
    return null;
  }
}

代码示例来源:origin: org.freemarker/freemarker

@Override
public Date parse(String s, int dateType) throws UnparsableValueException {
  try {
    return javaDateFormat.parse(s);
  } catch (ParseException e) {
    throw new UnparsableValueException(e.getMessage(), e);
  }
}

代码示例来源:origin: apache/maven

DateFormat dateParser = new java.text.SimpleDateFormat( effectiveDateFormat, java.util.Locale.US );
return dateParser.parse( s );
throw new XmlPullParserException( e.getMessage(), parser, e );

代码示例来源:origin: sohutv/cachecloud

/**
 * 获取上一分钟的字符串
 * 
 * @param currentMinuteStamp
 * @return
 */
private String getLastMinute(String currentMinuteStamp) {
  try {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
    Date currentDate = sdf.parse(currentMinuteStamp);
    Date lastMinute = DateUtils.addMinutes(currentDate, -1);
    return sdf.format(lastMinute);
  } catch (ParseException e) {
    logger.error(e.getMessage(), e);
    return null;
  }
}

代码示例来源:origin: org.springframework/spring-beans

/**
 * Parse the Date from the given text, using the specified DateFormat.
 */
@Override
public void setAsText(@Nullable String text) throws IllegalArgumentException {
  if (this.allowEmpty && !StringUtils.hasText(text)) {
    // Treat empty String as null value.
    setValue(null);
  }
  else if (text != null && this.exactDateLength >= 0 && text.length() != this.exactDateLength) {
    throw new IllegalArgumentException(
        "Could not parse date: it is not exactly" + this.exactDateLength + "characters long");
  }
  else {
    try {
      setValue(this.dateFormat.parse(text));
    }
    catch (ParseException ex) {
      throw new IllegalArgumentException("Could not parse date: " + ex.getMessage(), ex);
    }
  }
}

代码示例来源:origin: apache/maven

DateFormat dateParser = new java.text.SimpleDateFormat( effectiveDateFormat, java.util.Locale.US );
return dateParser.parse( s );
throw new XmlPullParserException( e.getMessage(), parser, e );

代码示例来源:origin: apache/incubator-gobblin

/**
 * Convert timestamp to hour (yyyymmddHHmmss to yyyymmddHH)
 *
 * @param watermark value
 * @return value in hour format
 */
synchronized private static Date extractFromTimestamp(String watermark) {
 final SimpleDateFormat inputFormat = new SimpleDateFormat(INPUTFORMAT);
 final SimpleDateFormat outputFormat = new SimpleDateFormat(OUTPUTFORMAT);
 Date outDate = null;
 try {
  Date date = inputFormat.parse(watermark);
  String dateStr = outputFormat.format(date);
  outDate = outputFormat.parse(dateStr);
 } catch (ParseException e) {
  LOG.error(e.getMessage(), e);
 }
 return outDate;
}

代码示例来源:origin: apache/drill

/**
 * Convenience method for parsing a Date from given String, using
 * currently configured date format (accessed using
 * {@link DeserializationConfig#getDateFormat()}).
 *<p>
 * Implementation will handle thread-safety issues related to
 * date formats such that first time this method is called,
 * date format is cloned, and cloned instance will be retained
 * for use during this deserialization round.
 */
public Date parseDate(String dateStr) throws IllegalArgumentException
{
  try {
    DateFormat df = getDateFormat();
    return df.parse(dateStr);
  } catch (ParseException e) {
    throw new IllegalArgumentException(String.format(
        "Failed to parse Date value '%s': %s", dateStr, e.getMessage()));
  }
}

代码示例来源:origin: apache/maven

DateFormat dateParser = new java.text.SimpleDateFormat( effectiveDateFormat, java.util.Locale.US );
return dateParser.parse( s );
throw new XmlPullParserException( e.getMessage(), parser, e );

代码示例来源:origin: apache/incubator-gobblin

/**
 * Convert timestamp to date (yyyymmddHHmmss to yyyymmdd)
 *
 * @param watermark value
 * @return value in date format
 */
synchronized private static Date extractFromTimestamp(String watermark) {
 final SimpleDateFormat inputFormat = new SimpleDateFormat(INPUTFORMAT);
 final SimpleDateFormat outputFormat = new SimpleDateFormat(OUTPUTFORMAT);
 Date outDate = null;
 try {
  Date date = inputFormat.parse(watermark);
  String dateStr = outputFormat.format(date);
  outDate = outputFormat.parse(dateStr);
 } catch (ParseException e) {
  LOG.error(e.getMessage(), e);
 }
 return outDate;
}

相关文章