mirror of
https://github.com/zxing/zxing.git
synced 2025-02-02 05:41:08 -08:00
Issue 1195 fix accounting for DST when target time DST status differs from now
git-svn-id: https://zxing.googlecode.com/svn/trunk@2216 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
776984bb8f
commit
b73a4af77b
|
@ -113,8 +113,12 @@ public final class CalendarResultHandler extends ResultHandler {
|
|||
long milliseconds = date.getTime();
|
||||
if (when.length() == 16 && when.charAt(15) == 'Z') {
|
||||
Calendar calendar = new GregorianCalendar();
|
||||
int offset = calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET);
|
||||
milliseconds += offset;
|
||||
// Account for time zone difference
|
||||
milliseconds += calendar.get(Calendar.ZONE_OFFSET);
|
||||
// Might need to correct for daylight savings time, but use target time since
|
||||
// now might be in DST but not then, or vice versa
|
||||
calendar.setTime(new Date(milliseconds));
|
||||
milliseconds += calendar.get(Calendar.DST_OFFSET);
|
||||
}
|
||||
ParsedResult.maybeAppend(DateFormat.getDateTimeInstance().format(milliseconds), result);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue