FileDocCategorySizeDatePackage
RFC977DateFormat.javaAPI DocApache James 2.3.15322Fri Jan 12 12:56:34 GMT 2007org.apache.mailet.dates

RFC977DateFormat

public class RFC977DateFormat extends Object implements SimplifiedDateFormat
A thread-safe date formatting class to produce dates formatted in accord with the specifications of RFC 977.

Fields Summary
private final SynchronizedDateFormat
internalLongDateFormat
Internal date formatter for long date formats
private final SynchronizedDateFormat
internalShortDateFormat
Internal date formatter for short date formats
Constructors Summary
public RFC977DateFormat()
Constructor for RFC977DateFormat

        internalLongDateFormat = new SynchronizedDateFormat("yyyyMMdd HHmmss", Locale.ENGLISH);
        internalShortDateFormat = new SynchronizedDateFormat("yyMMdd HHmmss", Locale.ENGLISH);
    
Methods Summary
public booleanequals(java.lang.Object obj)
Overrides equals

        if (this == obj) {
            return true;
        }
        if (!(obj instanceof RFC977DateFormat)) {
            return false;
        }
        RFC977DateFormat theOtherRFC977DateFormat = (RFC977DateFormat)obj;
        synchronized (this) {
            return ((internalShortDateFormat.equals(theOtherRFC977DateFormat.internalShortDateFormat)) &&
                    (internalLongDateFormat.equals(theOtherRFC977DateFormat.internalLongDateFormat)));
        }
    
public java.lang.Stringformat(java.util.Date d)
This method returns the long form of the RFC977 Date

return
java.lang.String
param
d Date

        return internalLongDateFormat.format(d);
    
public java.util.TimeZonegetTimeZone()
Gets the time zone.

return
the time zone associated with this SynchronizedDateFormat.

        synchronized(this) {
            return internalShortDateFormat.getTimeZone();
        }
    
public inthashCode()
Overrides hashCode

        return (int)(internalLongDateFormat.hashCode() & internalShortDateFormat.hashCode());
    
public booleanisLenient()
Tell whether date/time parsing is to be lenient.

return
whether this SynchronizedDateFormat is lenient.

        synchronized(this) {
            return internalShortDateFormat.isLenient();
        }
    
public java.util.Dateparse(java.lang.String source)
Parses text from the beginning of the given string to produce a date. The method may not use the entire text of the given string.

This method is designed to be thread safe, so we wrap our delegated parse method in an appropriate synchronized block.

param
source A String whose beginning should be parsed.
return
A Date parsed from the string.
throws
ParseException if the beginning of the specified string cannot be parsed.

        source = source.trim();
        if (source.indexOf(' ") == 6) {
            return internalShortDateFormat.parse(source);
        } else {
            return internalLongDateFormat.parse(source);
        }
    
public voidsetLenient(boolean lenient)
Specify whether or not date/time parsing is to be lenient. With lenient parsing, the parser may use heuristics to interpret inputs that do not precisely match this object's format. With strict parsing, inputs must match this object's format.

param
lenient when true, parsing is lenient
see
java.util.Calendar#setLenient

        synchronized(this) {
            internalShortDateFormat.setLenient(lenient);
            internalLongDateFormat.setLenient(lenient);
        }
    
public voidsetTimeZone(java.util.TimeZone zone)
Sets the time zone of this SynchronizedDateFormat object.

param
zone the given new time zone.

        synchronized(this) {
            internalShortDateFormat.setTimeZone(zone);
            internalLongDateFormat.setTimeZone(zone);
        }