Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Based on this output... I would think this is just how Java deals with DST? Seems like 2-3 AM goes into oblivion </p> <p><strong>See my comment below</strong></p> <pre><code>final Calendar reportingDate = Calendar.getInstance(); reportingDate.set(Calendar.YEAR, 2013); reportingDate.set(Calendar.MONTH, Calendar.MARCH); reportingDate.set(Calendar.DAY_OF_MONTH, 10); final Calendar targetTime = Calendar.getInstance(); targetTime.set(Calendar.AM_PM, Calendar.AM); targetTime.set(Calendar.HOUR_OF_DAY, 3); targetTime.set(Calendar.MINUTE, 0); targetTime.set(Calendar.SECOND, 0); targetTime.set(Calendar.MILLISECOND, 0); final Calendar combination = Calendar.getInstance(); combination.set(Calendar.YEAR, reportingDate.get(Calendar.YEAR)); combination.set(Calendar.MONTH, reportingDate.get(Calendar.MONTH)); combination.set(Calendar.DAY_OF_YEAR, reportingDate.get(Calendar.DAY_OF_YEAR)); combination.set(Calendar.HOUR, targetTime.get(Calendar.HOUR)); combination.set(Calendar.AM_PM, targetTime.get(Calendar.AM_PM)); combination.set(Calendar.MINUTE, targetTime.get(Calendar.MINUTE)); combination.set(Calendar.SECOND, targetTime.get(Calendar.SECOND)); combination.set(Calendar.MILLISECOND, targetTime.get(Calendar.MILLISECOND)); final long timeAtCombined = combination.getTimeInMillis(); final SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss.SSSZ"); sdf.setTimeZone(TimeZone.getTimeZone("US/Eastern")); // subtract one minute System.out.println(sdf.format(combination.getTime())); combination.add(Calendar.MILLISECOND, -1); System.out.println(sdf.format(combination.getTime())); // millis @ 3 System.out.println(sdf.format(new Date(timeAtCombined))); // millis @ 3 - 1ms System.out.println(sdf.format(new Date(timeAtCombined - 1))); </code></pre> <p>Output</p> <pre><code>03/10/2013 03:00:00.000-0400 03/10/2013 01:59:59.999-0500 03/10/2013 03:00:00.000-0400 03/10/2013 01:59:59.999-0500 </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload