FileDocCategorySizeDatePackage
Day.javaAPI DocApache Axis 1.44741Sat Apr 22 18:57:28 BST 2006org.apache.axis.types

Day

public class Day extends Object implements Serializable
Implementation of the XML Schema type gDay
author
Tom Jordahl
see
XML Schema 3.2.13

Fields Summary
int
day
String
timezone
Constructors Summary
public Day(int day)
Constructs a Day with the given values No timezone is specified


                    
         
        setValue(day);
    
public Day(int day, String timezone)
Constructs a Day with the given values, including a timezone string The timezone is validated but not used.

        setValue(day, timezone);
    
public Day(String source)
Construct a Day from a String in the format ---DD[timezone]

        if (source.length() < 5) {
            throw new NumberFormatException(
                    Messages.getMessage("badDay00"));
        }

        if (source.charAt(0) != '-" ||
            source.charAt(1) != '-" ||
            source.charAt(2) != '-" ) {
            throw new NumberFormatException(
                    Messages.getMessage("badDay00"));
        }

        setValue(Integer.parseInt(source.substring(3,5)),
                 source.substring(5));
    
Methods Summary
public booleanequals(java.lang.Object obj)

        if (!(obj instanceof Day)) return false;
        Day other = (Day) obj;
        if (obj == null) return false;
        if (this == obj) return true;

        boolean equals = (this.day == other.day);
        if (timezone != null) {
            equals = equals && timezone.equals(other.timezone);
        }
        return equals;
    
public intgetDay()

        return day;
    
public java.lang.StringgetTimezone()

        return timezone;
    
public inthashCode()
Return the value of day XORed with the hashCode of timezone iff one is defined.

return
an int value

        return null == timezone ? day : day ^ timezone.hashCode();
    
public voidsetDay(int day)
Set the day

        // validate day
        if (day < 1 || day > 31) {
            throw new NumberFormatException(
                    Messages.getMessage("badDay00"));
        }
        this.day = day;
    
public voidsetTimezone(java.lang.String timezone)

        // validate timezone
        if (timezone != null && timezone.length() > 0) {
            // Format [+/-]HH:MM
            if (timezone.charAt(0)=='+" || (timezone.charAt(0)=='-")) {
                    if (timezone.length() != 6 ||
                        !Character.isDigit(timezone.charAt(1)) ||
                        !Character.isDigit(timezone.charAt(2)) ||
                        timezone.charAt(3) != ':"              ||
                        !Character.isDigit(timezone.charAt(4)) ||
                        !Character.isDigit(timezone.charAt(5)))
                        throw new NumberFormatException(
                                Messages.getMessage("badTimezone00"));

            } else if (!timezone.equals("Z")) {
                throw new NumberFormatException(
                        Messages.getMessage("badTimezone00"));
            }
            // if we got this far, its good
            this.timezone = timezone;
        }
    
public voidsetValue(int day, java.lang.String timezone)

        setDay(day);
        setTimezone(timezone);
    
public voidsetValue(int day)

        setDay(day);
    
public java.lang.StringtoString()

        // use NumberFormat to ensure leading zeros
        NumberFormat nf = NumberFormat.getInstance();
        nf.setGroupingUsed(false);

        // Day
        nf.setMinimumIntegerDigits(2);
        String s = "---"  + nf.format(day);

        // timezone
        if (timezone != null) {
            s = s + timezone;
        }
        return s;