FileDocCategorySizeDatePackage
Month.javaAPI DocApache Axis 1.44829Sat Apr 22 18:57:26 BST 2006org.apache.axis.types

Month

public class Month extends Object implements Serializable
Implementation of the XML Schema type gMonth
author
Tom Jordahl
see
XML Schema 3.2.14

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


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

        setValue(month, timezone);
    
public Month(String source)
Construct a Month from a String in the format --MM--[timezone]

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

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

        setValue(Integer.parseInt(source.substring(2,4)),
                 source.substring(6));
    
Methods Summary
public booleanequals(java.lang.Object obj)

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

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

        return month;
    
public java.lang.StringgetTimezone()

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

return
an int value

        return null == timezone ? month : month ^ timezone.hashCode();
    
public voidsetMonth(int month)

        // validate month
        if (month < 1 || month > 12) {
            throw new NumberFormatException(
                    Messages.getMessage("badMonth00"));
        }
        this.month = month;
    
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 month, java.lang.String timezone)

        setMonth(month);
        setTimezone(timezone);
    
public voidsetValue(int month)

        setMonth(month);
    
public java.lang.StringtoString()

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

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

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