Java Code Examples for org.joda.time.Period#toString()

The following examples show how to use org.joda.time.Period#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FmtPeriod.java    From super-csv with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 * 
 * @throws SuperCsvCellProcessorException
 *             if value is null or not a Period
 */
public Object execute(final Object value, final CsvContext context) {
	validateInputNotNull(value, context);
	if (!(value instanceof Period)) {
		throw new SuperCsvCellProcessorException(Period.class, value,
				context, this);
	}
	final Period period = (Period) value;
	final String result;
	if (formatter != null) {
		result = period.toString(formatter);
	} else {
		result = period.toString();
	}

	return next.execute(result, context);
}
 
Example 2
Source File: StringColumnPeriodMapper.java    From jadira with Apache License 2.0 6 votes vote down vote up
@Override
  public String toNonNullValue(Period value) {
  	
  	final String periodString; 
if (STANDARD.equals(value.getPeriodType())) {
	periodString = value.toString();
} else {
	if (PeriodType.class.equals(value.getPeriodType().getClass())) {
		periodString = value.toString() + "{" + value.getPeriodType().getName() + "}";
	} else {
		
		throw new IllegalArgumentException("Subclasses of PeriodType are unsupported");
	}
}
return periodString;
  }
 
Example 3
Source File: MediathekShow.java    From zapp with MIT License 5 votes vote down vote up
public String getFormattedDuration() {
	int duration;
	try {
		duration = Integer.parseInt(this.duration);
	} catch (NumberFormatException e) {
		return "?";
	}

	Period period = Duration.standardSeconds(duration).toPeriod();
	PeriodFormatter formatter = (period.getHours() > 0) ? hourPeriodFormatter : secondsPeriodFormatter;
	return period.toString(formatter);
}
 
Example 4
Source File: PeriodFormatter.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public String print(Period object, Locale locale) {
	return object.toString();
}
 
Example 5
Source File: PeriodFormatter.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public String print(Period object, Locale locale) {
	return object.toString();
}
 
Example 6
Source File: PeriodFormatter.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public String print(Period object, Locale locale) {
	return object.toString();
}
 
Example 7
Source File: PeriodFormatter.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public String print(Period object, Locale locale) {
	return object.toString();
}
 
Example 8
Source File: PeriodAdapter.java    From nomulus with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public String marshal(@Nullable Period period) {
  return period == null ? null : period.toString();
}
 
Example 9
Source File: StreamSortSpec.java    From eagle with Apache License 2.0 4 votes vote down vote up
public void setWindowPeriod2(Period period) {
    this.windowPeriod = period.toString();
}