@Test public void testDateToDateConversion2() { Calendar localTime = Calendar.getInstance(TimeZone.getTimeZone("America/Chicago")); localTime.set(Calendar.MONTH, Calendar.JUNE); localTime.set(Calendar.DAY_OF_MONTH, 22); localTime.set(Calendar.YEAR, 2004); localTime.set(Calendar.HOUR, 23); localTime.set(Calendar.MINUTE, 15); localTime.set(Calendar.SECOND, 20); localTime.set(Calendar.AM_PM, Calendar.PM); Date converted = TimestampWithTimezone.createDate(localTime, Calendar.getInstance(TimeZone.getTimeZone("Europe/London"))); Calendar cal = Calendar.getInstance(); cal.setTime(converted); assertThat(cal.get(Calendar.MILLISECOND), is(0)); }
public static Date createDate( Calendar initial, Calendar target ) { if (target == null) { return createDate(initial); } long time = target.getTimeInMillis(); target = adjustCalendarForDate(initial, target); Date result = normalizeDate(target, true); target.setTimeInMillis(time); return result; }
TimestampWithTimezone { public static Date createDate( Calendar initial, Calendar target ) { if (target == null) { return createDate(initial); } long time = target.getTimeInMillis(); target = adjustCalendarForDate(initial, target); Date result = normalizeDate(target, true); target.setTimeInMillis(time); return result; } }
TimestampWithTimezone { public static Date createDate( Calendar initial, Calendar target ) { if (target == null) { return createDate(initial); } long time = target.getTimeInMillis(); target = adjustCalendarForDate(initial, target); Date result = normalizeDate(target, true); target.setTimeInMillis(time); return result; }  }
TimestampWithTimezone { public static Date createDate( Calendar initial, Calendar target ) { if (target == null) { return createDate(initial); } long time = target.getTimeInMillis(); target = adjustCalendarForDate(initial, target); Date result = normalizeDate(target, true); target.setTimeInMillis(time); return result; }  static Calendar getCalendar(); static void resetCalendar( TimeZone tz ); static Timestamp createTimestamp( Calendar initial,
                                             Calendar target ); static Time createTime( Calendar initial,
                                   Calendar target ); static Date createDate( Calendar initial,
                                   Calendar target ); static Time createTime( Calendar target ); static Date createDate( Calendar target ); static Timestamp createTimestamp( Calendar target ); }
TimestampWithTimezone { public static Date createDate( Calendar initial, Calendar target ) { if (target == null) { return createDate(initial); } long time = target.getTimeInMillis(); target = adjustCalendarForDate(initial, target); Date result = normalizeDate(target, true); target.setTimeInMillis(time); return result; }  static Calendar getCalendar(); static void resetCalendar( TimeZone tz ); static Timestamp createTimestamp( Calendar initial,
                                             Calendar target ); static Time createTime( Calendar initial,
                                   Calendar target ); static Date createDate( Calendar initial,
                                   Calendar target ); static Time createTime( Calendar target ); static Date createDate( Calendar target ); static Timestamp createTimestamp( Calendar target ); static DateFormat DATETIME_FORMAT; static DateFormat DATE_FORMAT; static DateFormat TIME_FORMAT; }