serge 01/09/27 09:32:35
Modified: src/java/org/apache/james/util RFC822DateFormat.java
Log:
Fixed time zone bug reported on user list and fixed by Danny.
Revision Changes Path
1.2 +11 -8
jakarta-james/src/java/org/apache/james/util/RFC822DateFormat.java
Index: RFC822DateFormat.java
===================================================================
RCS file:
/home/cvs/jakarta-james/src/java/org/apache/james/util/RFC822DateFormat.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- RFC822DateFormat.java 2001/05/11 09:52:30 1.1
+++ RFC822DateFormat.java 2001/09/27 16:32:35 1.2
@@ -20,12 +20,18 @@
* java.util.Date object and returns a nicely formatted String version of this,
formatted as per the
* RFC822 mail date format.
* @author Serge Knystautas <[EMAIL PROTECTED]>
- * @version 0.9
*/
public class RFC822DateFormat {
private static DateFormat df;
private static DecimalFormat tz;
+ private static TimeZone defaultTZ;
+ static {
+ df = new SimpleDateFormat("EE, d MMM yyyy HH:mm:ss", Locale.US);
+ tz = new DecimalFormat("00");
+ defaultTZ = TimeZone.getDefault();
+ }
+
/**
* SimpleDateFormat will handle most of this for us, but the
* timezone won't match, so we do that manually
@@ -34,18 +40,15 @@
* @param d Date
*/
public static String toString(Date d) {
- if (df == null) {
- df = new SimpleDateFormat("EE, d MMM yyyy HH:mm:ss",Locale.US);
- }
- if (tz == null) {
- tz = new DecimalFormat("00");
- }
-
StringBuffer sb = new StringBuffer(df.format(d));
sb.append(' ');
int min = TimeZone.getDefault().getRawOffset() / 1000 / 60;
+
+ if (defaultTZ.useDaylightTime() && defaultTZ.inDaylightTime(d)) {
+ min += 60;
+ }
if (min >= 0) {
sb.append('+');
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]