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 import com.sun.org.apache.xerces.internal.impl.dv.ValidationContext; 62 63 71 public class TimeDV extends AbstractDateTimeDV { 72 73 79 public Object getActualValue(String content, ValidationContext context) throws InvalidDatatypeValueException{ 80 try{ 81 return new DateTimeData(parse(content), this); 82 } catch(Exception ex){ 83 throw new InvalidDatatypeValueException("cvc-datatype-valid.1.2.1", new Object []{content, "time"}); 84 } 85 } 86 87 97 protected int[] parse(String str) throws SchemaDateTimeException{ 98 int len = str.length(); 99 int[] date = new int[TOTAL_SIZE]; 100 int[] timeZone = new int[2]; 101 102 date[CY]=YEAR; 105 date[M]=MONTH; 106 date[D]=DAY; 107 getTime(str, 0, len, date, timeZone); 108 109 111 validateDateTime(date, timeZone); 112 113 if ( date[utc]!=0 ) { 114 normalize(date, timeZone); 115 } 116 return date; 117 } 118 119 125 protected String dateToString(int[] date) { 126 StringBuffer message = new StringBuffer (16); 127 append(message, date[h], 2); 128 message.append(':'); 129 append(message, date[m], 2); 130 message.append(':'); 131 append(message, date[s], 2); 132 message.append('.'); 133 message.append(date[ms]); 134 append(message, (char)date[utc], 0); 135 return message.toString(); 136 } 137 138 } 139 140 141 | Popular Tags |