cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
Date date = cal.getTime();
SegmentedTimeline timeline = getTimeline();
// Add exception in included segments
cal.set(Calendar.YEAR, 2004);
cal.set(Calendar.MONTH, Calendar.MARCH);
cal.set(Calendar.DAY_OF_MONTH, 29);
cal.set(Calendar.HOUR_OF_DAY, 9);
cal.set(Calendar.MINUTE, 15);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
timeline.addException(cal.getTime());
long value = timeline.toTimelineValue(date);
long ms = timeline.toMillisecond(value);
Calendar cal2 = Calendar.getInstance(Locale.UK);
cal2.setTime(new Date(ms));
Date reverted = cal2.getTime();