protected static final Long parseUsingFormat(String text, DateTimeFormat fmt) { Date date = new Date(0); int num = fmt.parse(text, 0, date); return (num != 0) ? new Long(normalizeInLocalRange(date.getTime() - UTCDateBox.timezoneOffsetMillis(date))) : null; }
/** Formats the value provided with the specified DateTimeFormat */ protected static final String formatUsingFormat(Long value, DateTimeFormat fmt) { if (value == null) { return ""; } else { // midnight GMT Date date = new Date(0); // offset by timezone and value date.setTime(UTCDateBox.timezoneOffsetMillis(date) + value.longValue()); // format it return fmt.format(date); } }
private String generateTimeValue(long offsetFromMidnight) { // format the time in the local time zone long time = UTCDateBox.timezoneOffsetMillis(new Date(0)) + offsetFromMidnight; return timeFormat.format(new Date(time)); }