Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Issue 1195 fix accounting for DST when target time DST status differs…

… from now

git-svn-id: http://zxing.googlecode.com/svn/trunk@2216 59b500cc-1b3d-0410-9834-0bbf25fbcc57
  • Loading branch information...
commit bb443abde6c1e18d2863bc395d90a94c5698e25c 1 parent d707744
srowen authored
View
8 android/src/com/google/zxing/client/android/result/CalendarResultHandler.java
@@ -113,8 +113,12 @@ private static void appendTime(String when, StringBuilder result, boolean end, b
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);
}
Please sign in to comment.
Something went wrong with that request. Please try again.