4 * This file was generated by XMLSpy 2007sp2 Enterprise Edition.
6 * YOU SHOULD NOT MODIFY THIS FILE, BECAUSE IT WILL BE
7 * OVERWRITTEN WHEN YOU RE-RUN CODE GENERATION.
9 * Refer to the XMLSpy Documentation for further details.
10 * http://www.altova.com/xmlspy
14 package com.jmex.xml.types;
16 import java.util.Calendar;
19 public class SchemaDateTime extends SchemaCalendarBase {
22 public SchemaDateTime() {
26 public SchemaDateTime(SchemaDateTime newvalue) {
28 month = newvalue.month;
31 minute = newvalue.minute;
32 second = newvalue.second;
33 partsecond = newvalue.partsecond;
34 hasTZ = newvalue.hasTZ;
35 offsetTZ = newvalue.offsetTZ;
37 isempty = newvalue.isempty;
40 public SchemaDateTime(int newyear, int newmonth, int newday, int newhour, int newminute, int newsecond, double newpartsecond, int newoffsetTZ) {
41 setInternalValues( newyear, newmonth, newday, newhour, newminute, newsecond, newpartsecond, SchemaCalendarBase.TZ_OFFSET, newoffsetTZ);
45 public SchemaDateTime(int newyear, int newmonth, int newday, int newhour, int newminute, int newsecond, double newpartsecond) {
46 setInternalValues( newyear, newmonth, newday, newhour, newminute, newsecond, newpartsecond, SchemaCalendarBase.TZ_MISSING, 0);
50 public SchemaDateTime(Calendar newvalue) {
54 public SchemaDateTime(String newvalue) {
58 public SchemaDateTime(SchemaType newvalue) {
62 public SchemaDateTime(SchemaTypeCalendar newvalue) {
63 assign( (SchemaType)newvalue );
67 public int getYear() {
71 public int getMonth() {
79 public int getHour() {
83 public int getMinute() {
87 public int getSecond() {
91 public double getPartSecond() {
95 public int getMillisecond() {
96 return (int)java.lang.Math.round(partsecond*1000);
99 public int hasTimezone() {
103 public int getTimezoneOffset() {
104 if( hasTZ != TZ_OFFSET )
109 public Calendar getValue() {
110 Calendar cal = Calendar.getInstance();
111 cal.set( year, month-1, day, hour, minute, second);
112 cal.set( Calendar.MILLISECOND, getMillisecond() );
113 hasTZ = TZ_OFFSET; // necessary, because Calendar object always has timezone.
114 cal.set(Calendar.ZONE_OFFSET, offsetTZ * 60000);
115 //cal.setTimeZone( (TimeZone)new SimpleTimeZone(offsetTZ * 60000, "") );
119 public void setYear(int newyear) {
124 public void setMonth(int newmonth) {
129 public void setDay(int newday) {
134 public void setHour(int newhour) {
139 public void setMinute(int newminute) {
144 public void setSecond(int newsecond) {
149 public void setPartSecond(double newpartsecond) {
150 partsecond = newpartsecond;
154 public void setMillisecond(int newmillisecond) {
155 partsecond = (double)newmillisecond / 1000;
159 public void setTimezone(int newhasTZ, int newoffsetTZminutes ) {
161 offsetTZ = newoffsetTZminutes;
165 public void setValue(Calendar newvalue) {
166 if( newvalue == null ) {
170 year = newvalue.get( Calendar.YEAR );
171 month = newvalue.get( Calendar.MONTH ) + 1;
172 day = newvalue.get( Calendar.DAY_OF_MONTH );
173 hour = newvalue.get( Calendar.HOUR_OF_DAY );
174 minute = newvalue.get( Calendar.MINUTE );
175 second = newvalue.get( Calendar.SECOND );
176 setMillisecond( newvalue.get( Calendar.MILLISECOND ) );
181 public void parse(String s) {
183 String newvalue = SchemaNormalizedString.normalize(SchemaNormalizedString.WHITESPACE_COLLAPSE, s);
185 if( newvalue == null || newvalue.length() == 0)
187 else if (!parseDateTime(newvalue, DateTimePart_Date | DateTimePart_Time))
188 throw new StringParseException(newvalue + " cannot be converted to a dateTime value", 0);
191 public void assign(SchemaType newvalue) {
192 if( newvalue == null || newvalue.isNull() || newvalue.isEmpty())
194 else if( newvalue instanceof SchemaDateTime ) {
195 setInternalValues( ((SchemaDateTime)newvalue).year, ((SchemaDateTime)newvalue).month, ((SchemaDateTime)newvalue).day, ((SchemaDateTime)newvalue).hour, ((SchemaDateTime)newvalue).minute, ((SchemaDateTime)newvalue).second, ((SchemaDateTime)newvalue).partsecond, ((SchemaDateTime)newvalue).hasTZ, ((SchemaDateTime)newvalue).offsetTZ);
198 else if( newvalue instanceof SchemaDate ) {
199 setInternalValues( ((SchemaDate)newvalue).year, ((SchemaDate)newvalue).month, ((SchemaDate)newvalue).day, 0, 0, 0, 0.0, SchemaCalendarBase.TZ_MISSING, 0);
202 else if( newvalue instanceof SchemaString )
203 parse( newvalue.toString() );
205 throw new TypesIncompatibleException( newvalue, this );
209 public Object clone() {
210 return new SchemaDateTime( this );
213 public String toString() {
216 StringBuffer s = new StringBuffer();
217 s.append( toDateString() );
219 s.append( toTimeString() );
223 public static SchemaDateTime now() {
224 return new SchemaDateTime(Calendar.getInstance());
227 // ---------- interface SchemaTypeCalendar ----------
228 public int calendarType() {
229 return CALENDAR_VALUE_DATETIME;
232 public SchemaDateTime dateTimeValue() {
233 return new SchemaDateTime( this );
236 public SchemaDate dateValue() {
237 return new SchemaDate( this );
240 public SchemaTime timeValue() {
241 return new SchemaTime( this ); // result.hasTZ = hasTZ;