1 57 58 package com.sun.org.apache.xerces.internal.impl.dv.xs; 59 60 import com.sun.org.apache.xerces.internal.impl.dv.InvalidDatatypeValueException; 61 62 70 public class DateDV extends DateTimeDV { 71 72 public Object getActualValue(String content) throws InvalidDatatypeValueException { 73 try{ 74 return new DateTimeData(parse(content), this); 75 } catch(Exception ex){ 76 throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object []{content, "date"}); 77 } 78 } 79 80 89 protected int[] parse(String str) throws SchemaDateTimeException{ 90 int len = str.length(); 91 int[] date = new int[TOTAL_SIZE]; 92 int[] timeZone = new int[2]; 93 94 int end = getDate(str, 0, len, date); 95 parseTimeZone (str, end, len, date, timeZone); 96 97 validateDateTime(date, timeZone); 100 101 if ( date[utc]!=0 && date[utc]!='Z' ) { 102 normalize(date, timeZone); 103 } 104 return date; 105 } 106 107 protected String dateToString(int[] date) { 108 StringBuffer message = new StringBuffer (25); 109 append(message, date[CY], 4); 110 message.append('-'); 111 append(message, date[M], 2); 112 message.append('-'); 113 append(message, date[D], 2); 114 append(message, (char)date[utc], 0); 115 return message.toString(); 116 } 117 118 } 119 | Popular Tags |