Changeset 283

Show
Ignore:
Timestamp:
09/04/08 08:59:26 PM (4 months ago)
Author:
octorian
Message:

Fixed time zone offset computation for date/time strings (#103)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/LogicMail-1.0/LogicMail/src/org/logicprobe/LogicMail/util/StringParser.java

    r277 r283  
    5252 */ 
    5353public class StringParser { 
     54    private static final long ONE_SECOND  = 1000; 
     55    private static final long ONE_MINUTE  = ONE_SECOND * 60; 
     56    private static final long ONE_HOUR    = ONE_MINUTE * 60; 
     57     
    5458    private StringParser() { } 
    5559     
     
    323327        buf.append(' '); 
    324328         
    325         int tzOffset = (cal.getTimeZone().getRawOffset())/36000; 
     329        int tzOffset = cal.getTimeZone().getOffset( 
     330                1, 
     331                cal.get(Calendar.YEAR), 
     332                cal.get(Calendar.MONTH), 
     333                cal.get(Calendar.DAY_OF_MONTH), 
     334                cal.get(Calendar.DAY_OF_WEEK), 
     335                (int)((long)cal.get(Calendar.HOUR_OF_DAY) * ONE_HOUR 
     336                    + cal.get(Calendar.MINUTE) * ONE_MINUTE 
     337                    + cal.get(Calendar.SECOND) * ONE_SECOND) 
     338                )/36000; 
     339         
    326340        if(tzOffset < 0) { 
    327341            buf.append(NumberUtilities.toString(tzOffset, 10, 5));