FileDocCategorySizeDatePackage
DateDV.javaAPI DocJava SE 5 API4715Fri Aug 26 14:55:48 BST 2005com.sun.org.apache.xerces.internal.impl.dv.xs

DateDV

public class DateDV extends DateTimeDV
Validator for datatype (W3C Schema datatypes)
author
Elena Litani
author
Gopal Sharma, SUN Microsystems Inc.
version
$Id: DateDV.java,v 1.9 2003/05/08 20:11:55 elena Exp $

Fields Summary
Constructors Summary
Methods Summary
protected java.lang.StringdateToString(int[] date)

        StringBuffer message = new StringBuffer(25);
        append(message, date[CY], 4);
        message.append('-");
        append(message, date[M], 2);
        message.append('-");
        append(message, date[D], 2);
        append(message, (char)date[utc], 0);
        return message.toString();
    
public java.lang.ObjectgetActualValue(java.lang.String content)

        try{
            return new DateTimeData(parse(content), this);
        } catch(Exception ex){
            throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object[]{content, "date"});
        }
    
protected int[]parse(java.lang.String str)
Parses, validates and computes normalized version of dateTime object

param
str The lexical representation of dateTime object CCYY-MM-DD with possible time zone Z or (-),(+)hh:mm
param
date uninitialized date object
return
normalized dateTime representation
exception
SchemaDateTimeException Invalid lexical representation

        int len = str.length();
        int[] date = new int[TOTAL_SIZE];
        int[] timeZone = new int[2];

        int end = getDate(str, 0, len, date);
        parseTimeZone (str, end, len, date, timeZone);

        //validate and normalize
        //REVISIT: do we need SchemaDateTimeException?
        validateDateTime(date, timeZone);

        if ( date[utc]!=0 && date[utc]!='Z" ) {
            normalize(date, timeZone);
        }
        return date;