1 36 package org.columba.ristretto.imap; 37 38 import java.util.Calendar ; 39 import java.util.Date ; 40 import java.util.TimeZone ; 41 42 50 public class IMAPDateTime extends IMAPDate { 51 52 55 public String toString() { 56 Calendar cal = Calendar.getInstance(tz); 57 cal.setTime(date); 58 59 StringBuffer result = new StringBuffer (); 60 result.append('\"'); 61 62 result.append(super.toString()); 64 65 result.append(' '); 66 67 int hour = cal.get(Calendar.HOUR_OF_DAY); 69 if( hour < 10 ) { 70 result.append('0'); 71 } 72 result.append(hour); 73 74 result.append(':'); 75 int minute = cal.get(Calendar.MINUTE); 76 if( minute < 10 ) { 77 result.append('0'); 78 } 79 result.append(minute); 80 81 result.append(':'); 82 int second = cal.get(Calendar.SECOND); 83 if( second < 10 ) { 84 result.append('0'); 85 } 86 result.append(second); 87 88 result.append(' '); 89 int rawOffset = cal.getTimeZone().getRawOffset(); 92 if( rawOffset < 0 ) { 93 int hours = (-rawOffset) / 3600000; 94 int minutes = ((-rawOffset) % 3600000) / 60000; 95 96 result.append( "-"); 97 if( hours < 10 ) { 98 result.append('0'); 99 } 100 result.append( hours); 101 102 if( minutes < 10 ) { 103 result.append('0'); 104 } 105 result.append(minutes); 106 } else { 107 int hours = rawOffset / 3600000; 108 int minutes = (rawOffset % 3600000) / 60000; 109 110 result.append( "+" ); 111 if( hours < 10 ) { 112 result.append('0'); 113 } 114 result.append( hours); 115 116 if( minutes < 10 ) { 117 result.append('0'); 118 } 119 result.append(minutes); 120 } 121 122 123 result.append('\"'); 124 return result.toString(); 125 } 126 131 public IMAPDateTime() { 132 super(); 133 } 134 140 public IMAPDateTime(Date date) { 141 super(date); 142 } 143 149 public IMAPDateTime(Date date, TimeZone tz) { 150 super(date, tz); 151 } 152 } 153 | Popular Tags |