For a project, I want a dateOptionalTime parser that uses <max value> instead of 0 for parts that were omitted in the input.
e.g: 2010-01-01T10:00:00 -> 2010-01-01T10:00:00 2010-01-01T10:00 -> 2010-01-01T10:00:59 2010-01-01 -> 2010-01-01T23:59:59 2010 -> 2010-12-31T23:59:59 My idea is to do it (roughly) as described below, but I was wondering if there is a more elegant way: builder = new DateTimeFormatterBuilder(): yyyy = builder.appendYear(4, 4).toFormatter(); yyyyMM = builder.appendLiteral('-').appendMonthOfYear(2).toFormatter(); yyyyMMdd = builder.appendLiteral('-').appendDayOfMonth(2).toFormatter(); yyyyMMddHH = builder.appendLiteral('-').appendHourOfDay(2).toFormatter(); ... DateTime result = null; try { result = yyyy.parseDateTime().withMonthOfYear(12).withDayOfMonth(31).withTime(23,59,59,0); } catch (IllegalArgumentException iae) {} try { result = yyyyMM.parseDateTime().withDayOfMonth(31).withTime(23,59,59,0); } catch (IllegalArgumentException iae) {} try { result = yyyyMMdd.parseDateTime().withTime(23,59,59,0); } catch (IllegalArgumentException iae) {} try { result = yyyyMMddHH.parseDateTime().withMinuteOfHour(59).withSecondOfMinute(59); } catch (IllegalArgumentException iae) {} ... WDYT? Karel ------------------------------------------------------------------------------ _______________________________________________ Joda-interest mailing list Joda-interest@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/joda-interest