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:
srowen 2012-03-03 16:36:37 +00:00
parent 776984bb8f
commit b73a4af77b

View file

@ -113,8 +113,12 @@ public final class CalendarResultHandler extends ResultHandler {
long milliseconds = date.getTime(); long milliseconds = date.getTime();
if (when.length() == 16 && when.charAt(15) == 'Z') { if (when.length() == 16 && when.charAt(15) == 'Z') {
Calendar calendar = new GregorianCalendar(); Calendar calendar = new GregorianCalendar();
int offset = calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET); // Account for time zone difference
milliseconds += offset; 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); ParsedResult.maybeAppend(DateFormat.getDateTimeInstance().format(milliseconds), result);
} }