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 51 public class IMAPDate { 52 53 protected static final String [] month = { 54 "Jan", 55 "Feb", 56 "Mar", 57 "Apr", 58 "May", 59 "Jun", 60 "Jul", 61 "Aug", 62 "Sep", 63 "Oct", 64 "Nov", 65 "Dec" 66 }; 67 protected Date date; 68 protected TimeZone tz; 69 70 76 public IMAPDate( Date date, TimeZone tz ) { 77 this.date = date; 78 this.tz = tz; 79 } 80 81 87 public IMAPDate( Date date) { 88 this(date, TimeZone.getDefault()); 89 } 90 91 96 public IMAPDate() { 97 this(new Date (), TimeZone.getDefault()); 98 } 99 100 101 104 public String toString() { 105 Calendar cal = Calendar.getInstance(tz); 106 cal.setTime(date); 107 108 StringBuffer result = new StringBuffer (); 109 int date = cal.get(Calendar.DATE); 110 if( date < 10 ) { 111 result.append('0'); 112 } 113 result.append(date); 114 115 result.append('-'); 116 117 result.append(month[cal.get(Calendar.MONTH)]); 118 119 result.append('-'); 120 121 result.append(cal.get(Calendar.YEAR)); 122 123 return result.toString(); 124 } 125 } 126 | Popular Tags |