@Test public void testFormatForPrecision() { PointInTime t = new PointInTime(1975, 7, 23, 10, 23, 55, 123); Assert.assertEquals("1975", HL7DateTimeFormat.forPrecision(Precision.YEAR).print(t)); Assert.assertEquals("197507", HL7DateTimeFormat.forPrecision(Precision.MONTH).print(t)); Assert.assertEquals("19750723", HL7DateTimeFormat.forPrecision(Precision.DATE).print(t)); Assert.assertEquals("1975072310", HL7DateTimeFormat.forPrecision(Precision.HOUR).print(t)); Assert.assertEquals("197507231023", HL7DateTimeFormat.forPrecision(Precision.MINUTE).print(t)); Assert.assertEquals("19750723102355", HL7DateTimeFormat.forPrecision(Precision.SECOND).print(t)); Assert.assertEquals("19750723102355.123", HL7DateTimeFormat.forPrecision(Precision.MILLISECOND).print(t)); }
public static DateTimeFormatter forPrecision(Precision p) { switch (p) { case MILLISECOND: return dateTime(); case SECOND: return PointInTimeFormat.forPattern("yyyyMMddHHmmss"); case MINUTE: return PointInTimeFormat.forPattern("yyyyMMddHHmm"); case HOUR: return PointInTimeFormat.forPattern("yyyyMMddHH"); case DATE: return PointInTimeFormat.forPattern("yyyyMMdd"); case MONTH: return PointInTimeFormat.forPattern("yyyyMM"); default: return PointInTimeFormat.forPattern("yyyy"); } }
HL7DateTimeFormat { public static DateTimeFormatter forPrecision(Precision p) { switch (p) { case MILLISECOND: return dateTime(); case SECOND: return PointInTimeFormat.forPattern("yyyyMMddHHmmss"); case MINUTE: return PointInTimeFormat.forPattern("yyyyMMddHHmm"); case HOUR: return PointInTimeFormat.forPattern("yyyyMMddHH"); case DATE: return PointInTimeFormat.forPattern("yyyyMMdd"); case MONTH: return PointInTimeFormat.forPattern("yyyyMM"); default: return PointInTimeFormat.forPattern("yyyy"); } } }
HL7DateTimeFormat { public static DateTimeFormatter forPrecision(Precision p) { switch (p) { case MILLISECOND: return dateTime(); case SECOND: return PointInTimeFormat.forPattern("yyyyMMddHHmmss"); case MINUTE: return PointInTimeFormat.forPattern("yyyyMMddHHmm"); case HOUR: return PointInTimeFormat.forPattern("yyyyMMddHH"); case DATE: return PointInTimeFormat.forPattern("yyyyMMdd"); case MONTH: return PointInTimeFormat.forPattern("yyyyMM"); default: return PointInTimeFormat.forPattern("yyyy"); } } protected  HL7DateTimeFormat(); }
HL7DateTimeFormat { public static DateTimeFormatter forPrecision(Precision p) { switch (p) { case MILLISECOND: return dateTime(); case SECOND: return PointInTimeFormat.forPattern("yyyyMMddHHmmss"); case MINUTE: return PointInTimeFormat.forPattern("yyyyMMddHHmm"); case HOUR: return PointInTimeFormat.forPattern("yyyyMMddHH"); case DATE: return PointInTimeFormat.forPattern("yyyyMMdd"); case MONTH: return PointInTimeFormat.forPattern("yyyyMM"); default: return PointInTimeFormat.forPattern("yyyy"); } } protected  HL7DateTimeFormat(); static DateTimeFormatter dateTime(); static DateTimeFormatter forPointInTime(PointInTime t); static DateTimeFormatter forPrecision(Precision p); static PointInTimeFormatter pointInTimeParser(); static PointInTime parse(String text); static PointInTime toPointInTime(String text); static LocalDateTime toLocalDateTime(String text); }
HL7DateTimeFormat { public static DateTimeFormatter forPrecision(Precision p) { switch (p) { case MILLISECOND: return dateTime(); case SECOND: return PointInTimeFormat.forPattern("yyyyMMddHHmmss"); case MINUTE: return PointInTimeFormat.forPattern("yyyyMMddHHmm"); case HOUR: return PointInTimeFormat.forPattern("yyyyMMddHH"); case DATE: return PointInTimeFormat.forPattern("yyyyMMdd"); case MONTH: return PointInTimeFormat.forPattern("yyyyMM"); default: return PointInTimeFormat.forPattern("yyyy"); } } protected  HL7DateTimeFormat(); static DateTimeFormatter dateTime(); static DateTimeFormatter forPointInTime(PointInTime t); static DateTimeFormatter forPrecision(Precision p); static PointInTimeFormatter pointInTimeParser(); static PointInTime parse(String text); static PointInTime toPointInTime(String text); static LocalDateTime toLocalDateTime(String text);  }