Java Code Examples for org.joda.time.format.ISODateTimeFormat#localTimeParser()

The following examples show how to use org.joda.time.format.ISODateTimeFormat#localTimeParser() . 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: PrimitiveColumnMetadata.java    From Bats with Apache License 2.0 6 votes vote down vote up
@Override
public DateTimeFormatter dateTimeFormatter() {
  String formatValue = format();
  try {
    switch (type) {
      case TIME:
        return formatValue == null
          ? ISODateTimeFormat.localTimeParser() : DateTimeFormat.forPattern(formatValue);
      case DATE:
        formatValue = format();
        return formatValue == null
          ? ISODateTimeFormat.localDateParser() : DateTimeFormat.forPattern(formatValue);
      case TIMESTAMP:
        formatValue = format();
        return formatValue == null
          ? ISODateTimeFormat.dateTimeNoMillis() : DateTimeFormat.forPattern(formatValue);
      default:
        throw new IllegalArgumentException("Column is not a date/time type: " + type.toString());
    }
  } catch (IllegalArgumentException e) {
    throw new IllegalArgumentException(String.format("The format \"%s\" is not valid for type %s",
        formatValue, type), e);
  }
}
 
Example 2
Source File: ParseLocalTimeTest.java    From super-csv with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
	formatter = ISODateTimeFormat.localTimeParser();
	processor1 = new ParseLocalTime();
	processor2 = new ParseLocalTime(formatter);
	processorChain1 = new ParseLocalTime(new IdentityTransform());
	processorChain2 = new ParseLocalTime(formatter, new IdentityTransform());
	processors = Arrays.asList(processor1, processor2, processorChain1,
			processorChain2);
}