FileDocCategorySizeDatePackage
INTERNALDATE.javaAPI DocGlassfish v2 API5033Mon May 14 15:28:44 BST 2007com.sun.mail.imap.protocol

INTERNALDATE

public class INTERNALDATE extends Object implements Item
This class
version
1.17, 07/05/04
author
John Mani

Fields Summary
static final char[]
name
public int
msgno
protected Date
date
private static MailDateFormat
mailDateFormat
private static SimpleDateFormat
df
Constructors Summary
public INTERNALDATE(FetchResponse r)
Constructor


          
         
	msgno = r.getNumber();
	r.skipSpaces();
	String s = r.readString();
	if (s == null)
	    throw new ParsingException("INTERNALDATE is NIL");
	try {
	    date = mailDateFormat.parse(s);
	} catch (ParseException pex) {
	    throw new ParsingException("INTERNALDATE parse error");
	}
    
Methods Summary
public static java.lang.Stringformat(java.util.Date d)
Format given Date object into INTERNALDATE string


                
         
	/*
	 * SimpleDateFormat objects aren't thread safe, so rather
	 * than create a separate such object for each request,
	 * we create one object and synchronize its use here
	 * so that only one thread is using it at a time.  This
	 * trades off some potential concurrency for speed in the
	 * common case.
	 *
	 * This method is only used when formatting the date in a
	 * message that's being appended to a folder.
	 */
	StringBuffer sb = new StringBuffer();
	synchronized (df) {
	    df.format(d, sb, new FieldPosition(0));
	}

	// compute timezone offset string
	// XXX - Yes, I know this is deprecated
	int rawOffsetInMins = -d.getTimezoneOffset();
	/*
	 * XXX - in JavaMail 1.4 / J2SE 1.4, possibly replace above with:
	 *
	TimeZone tz = TimeZone.getDefault();
	int offset = tz.getOffset(d);	// get offset from GMT
	int rawOffsetInMins = offset / 60 / 1000; // offset from GMT in mins
	 */
	if (rawOffsetInMins < 0) {
	    sb.append('-");
	    rawOffsetInMins = (-rawOffsetInMins);
	} else
	    sb.append('+");
	
	int offsetInHrs = rawOffsetInMins / 60;
	int offsetInMins = rawOffsetInMins % 60;

	sb.append(Character.forDigit((offsetInHrs/10), 10));
	sb.append(Character.forDigit((offsetInHrs%10), 10));
	sb.append(Character.forDigit((offsetInMins/10), 10));
	sb.append(Character.forDigit((offsetInMins%10), 10));

	return sb.toString();
    
public java.util.DategetDate()

	return date;