Actually, it’s not my fault. I got the following message from Al Jeyapal, pointing out the error of my ways.
From: Al Jeyapal To: woody@chaosinmotion.com Date: Tue, 14 Jul 2009 14:29:36 +1000 Subject: BerUTC Parsing in ASN.1 Library G'day mate, I'm not sure if you're still maintaining the code for this library, but thought I'd send this through in case you are. There is a slight problem with how BerUTCTime nodes are created. The SimpleDateFormat needs to have it's time zone set explicitly to UTC, else it will interpret the date using the time zone from the current locale. Diff is as follows: @@ -40,6 +40,7 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.TimeZone; /** * Represents a UTC time object. @@ -98,6 +99,7 @@ { if (gFormat == null) { gFormat = new SimpleDateFormat("yyMMddHHmmss"); + gFormat.setTimeZone(TimeZone.getTimeZone("UTC")); } } Cheers, Al
Fixed in the current build.
Thanks!
Of course I feel stupid: I never noticed the problem before. However, in all of the protocols in all of the places where I’ve used the asn.1 library (and I still use it; I prefer asn.1 data streams to XML in my own ad-hoc protocols), I never had need to use the UTC time.
G’figure.