@Test public void testYear( ) { PointInTimeToStringConverter pointInTimeToStringConverter = new PointInTimeToStringConverter(); PointInTime t = new PointInTime(2011); assertEquals("2011", pointInTimeToStringConverter.convert(t)); }
@Override public String convert(PointInTime source) { if (source == null) { return NA_VALUE; } DateTimeFormatter fmt = null; Precision p = source.getPrecision(); if (format != null) { fmt = DateTimeFormat.forPattern(format); } else { switch (p) { case MILLISECOND: case SECOND: case MINUTE: fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm"); break; case HOUR: case DATE: fmt = DateTimeFormat.forPattern("yyyy-MM-dd"); break; case MONTH: fmt = DateTimeFormat.forPattern("yyyy-MM"); break; default: fmt = DateTimeFormat.forPattern("yyyy"); } } return fmt.print(source); }
PointInTimeToStringConverter implements Converter<PointInTime, String> { @Override public String convert(PointInTime source) { if (source == null) { return NA_VALUE; } DateTimeFormatter fmt = null; Precision p = source.getPrecision(); if (format != null) { fmt = DateTimeFormat.forPattern(format); } else { switch (p) { case MILLISECOND: case SECOND: case MINUTE: fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm"); break; case HOUR: case DATE: fmt = DateTimeFormat.forPattern("yyyy-MM-dd"); break; case MONTH: fmt = DateTimeFormat.forPattern("yyyy-MM"); break; default: fmt = DateTimeFormat.forPattern("yyyy"); } } return fmt.print(source); } }
PointInTimeToStringConverter implements Converter<PointInTime, String> { @Override public String convert(PointInTime source) { if (source == null) { return NA_VALUE; } DateTimeFormatter fmt = null; Precision p = source.getPrecision(); if (format != null) { fmt = DateTimeFormat.forPattern(format); } else { switch (p) { case MILLISECOND: case SECOND: case MINUTE: fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm"); break; case HOUR: case DATE: fmt = DateTimeFormat.forPattern("yyyy-MM-dd"); break; case MONTH: fmt = DateTimeFormat.forPattern("yyyy-MM"); break; default: fmt = DateTimeFormat.forPattern("yyyy"); } } return fmt.print(source); } PointInTimeToStringConverter();  PointInTimeToStringConverter(String format); }
PointInTimeToStringConverter implements Converter<PointInTime, String> { @Override public String convert(PointInTime source) { if (source == null) { return NA_VALUE; } DateTimeFormatter fmt = null; Precision p = source.getPrecision(); if (format != null) { fmt = DateTimeFormat.forPattern(format); } else { switch (p) { case MILLISECOND: case SECOND: case MINUTE: fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm"); break; case HOUR: case DATE: fmt = DateTimeFormat.forPattern("yyyy-MM-dd"); break; case MONTH: fmt = DateTimeFormat.forPattern("yyyy-MM"); break; default: fmt = DateTimeFormat.forPattern("yyyy"); } } return fmt.print(source); } PointInTimeToStringConverter();  PointInTimeToStringConverter(String format); @Override String convert(PointInTime source); }
PointInTimeToStringConverter implements Converter<PointInTime, String> { @Override public String convert(PointInTime source) { if (source == null) { return NA_VALUE; } DateTimeFormatter fmt = null; Precision p = source.getPrecision(); if (format != null) { fmt = DateTimeFormat.forPattern(format); } else { switch (p) { case MILLISECOND: case SECOND: case MINUTE: fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm"); break; case HOUR: case DATE: fmt = DateTimeFormat.forPattern("yyyy-MM-dd"); break; case MONTH: fmt = DateTimeFormat.forPattern("yyyy-MM"); break; default: fmt = DateTimeFormat.forPattern("yyyy"); } } return fmt.print(source); } PointInTimeToStringConverter();  PointInTimeToStringConverter(String format); @Override String convert(PointInTime source);  }