org.joda.time.Duration#parse ( )源码实例Demo

下面列出了org.joda.time.Duration#parse ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: super-csv   文件: ParseDuration.java
/**
 * {@inheritDoc}
 * 
 * @throws SuperCsvCellProcessorException
 *             if value is null or is not a String
 */
public Object execute(final Object value, final CsvContext context) {
	validateInputNotNull(value, context);
	if (!(value instanceof String)) {
		throw new SuperCsvCellProcessorException(String.class, value,
				context, this);
	}
	final Duration result;
	try {
		result = Duration.parse((String) value);
	} catch (IllegalArgumentException e) {
		throw new SuperCsvCellProcessorException(
				"Failed to parse value as a Duration", context, this, e);
	}
	return next.execute(result, context);
}
 
源代码2 项目: nomulus   文件: DurationTranslatorFactory.java
@Override
protected SimpleTranslator<Duration, String> createTranslator() {
  return new SimpleTranslator<Duration, String>() {
    @Override
    public Duration loadValue(String datastoreValue) {
      return Duration.parse(datastoreValue);
    }

    @Override
    public String saveValue(Duration pojoValue) {
      return pojoValue.toString();
    }};
}
 
源代码3 项目: spring-analysis-note   文件: DurationFormatter.java
@Override
public Duration parse(String text, Locale locale) throws ParseException {
	return Duration.parse(text);
}
 
源代码4 项目: java-technology-stack   文件: DurationFormatter.java
@Override
public Duration parse(String text, Locale locale) throws ParseException {
	return Duration.parse(text);
}
 
源代码5 项目: lams   文件: DurationFormatter.java
@Override
public Duration parse(String text, Locale locale) throws ParseException {
	return Duration.parse(text);
}
 
源代码6 项目: arctic-sea   文件: DurationConverter.java
@Override
public Duration convert(String source) {
    return Duration.parse(source);
}
 
源代码7 项目: spring4-understanding   文件: DurationFormatter.java
@Override
public Duration parse(String text, Locale locale) throws ParseException {
	return Duration.parse(text);
}
 
源代码8 项目: beam   文件: StreamingDataflowWorkerOptions.java
@Override
public Duration create(PipelineOptions options) {
  Duration period =
      Duration.parse(System.getProperty("windmill.harness_update_reporting_period", "PT10S"));
  return period.isLongerThan(Duration.ZERO) ? period : Duration.standardSeconds(10);
}
 
源代码9 项目: beam   文件: StreamingDataflowWorkerOptions.java
@Override
public Duration create(PipelineOptions options) {
  Duration period =
      Duration.parse(System.getProperty("windmill.global_get_config_refresh_period", "PT120S"));
  return period.isLongerThan(Duration.ZERO) ? period : Duration.standardMinutes(2);
}
 
源代码10 项目: activitystreams   文件: Adapters.java
public Duration apply(String v) {
  return Duration.parse(v);
}
 
/**
 * Gson invokes this call-back method during deserialization when it encounters a field of the
 * specified type.
 * <p>
 * In the implementation of this call-back method, you should consider invoking
 * {@link JsonDeserializationContext#deserialize(JsonElement, Type)} method to create objects
 * for any non-trivial field of the returned object. However, you should never invoke it on the
 * the same type passing {@code json} since that will cause an infinite loop (Gson will call your
 * call-back method again).
 * @param json The Json data being deserialized
 * @param typeOfT The type of the Object to deserialize to
 * @return a deserialized object of the specified type typeOfT which is a subclass of {@code T}
 * @throws JsonParseException if json is not in the expected format of {@code typeOfT}
 */
@Override
public Duration deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
    throws JsonParseException
{
  // Do not try to deserialize null or empty values
  if (json.getAsString() == null || json.getAsString().isEmpty())
  {
    return null;
  }

  return Duration.parse(json.getAsString());
}