public DateValue(String dateString) throws XPathException { Perl5Util util = new Perl5Util(); if (!util.match(regex, dateString)) throw new XPathException( "Type error: string " + dateString + " cannot be cast into an xs:date"); String part = util.group(1); int era = 1; if (part != null && part.equals("-")) era = -1; part = util.group(2); int year = Integer.parseInt(part) * era; part = util.group(3); int month = Integer.parseInt(part); part = util.group(4); int day = Integer.parseInt(part); int tz = 0; part = util.group(10); if (part != null && part.length() > 0 && (!part.equals("Z"))) { if (!util.match(tzre, part)) throw new XPathException("Type error: error in  timezone: " + part); part = util.group(2); tz = Integer.parseInt(part) * 60; part = util.group(3); if (part != null) { int tzminute = Integer.parseInt(part); tz += tzminute; } part = util.group(1); if (part.equals("-")) tz *= -1; } SimpleTimeZone zone = new SimpleTimeZone(tzOffset * 60000, "LLL"); if (explicitTimeZone) calendar = new GregorianCalendar(zone); else { calendar = new GregorianCalendar(); tzOffset = (calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET)) / 60000; } calendar.setLenient(false); calendar.set(year, month - 1, day); if (explicitTimeZone) calendar.set(Calendar.ZONE_OFFSET, tzOffset * 60000); System.out.println(calendar.getTimeZone().getDisplayName()); try { date = calendar.getTime(); } catch (Exception e) { throw new XPathException( "Type error: string " + dateString + " cannot be cast into an xs:date"); }
public DateValue() { calendar = new GregorianCalendar(); tzOffset = (calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET)) / 60000; date = calendar.getTime();
	public DateValue(String dateString) throws XPathException {		Perl5Util util = new Perl5Util();		if (!util.match(regex, dateString))			throw new XPathException(				"Type error: string "					+ dateString					+ " cannot be cast into an xs:date");		String part = util.group(1);		int era = 1;		if (part != null && part.equals("-"))			era = -1;		part = util.group(2);		int year = Integer.parseInt(part) * era;		part = util.group(3);		int month = Integer.parseInt(part);		part = util.group(4);		int day = Integer.parseInt(part);		int tz = 0;		part = util.group(10);		if (part != null && part.length() > 0 && (!part.equals("Z"))) {			if (!util.match(tzre, part))				throw new XPathException("Type error: error in  timezone: " + part);			part = util.group(2);			tz = Integer.parseInt(part) * 60;			part = util.group(3);			if (part != null) {				int tzminute = Integer.parseInt(part);				tz += tzminute;			}			part = util.group(1);			if (part.equals("-"))				tz *= -1;		}		SimpleTimeZone zone = new SimpleTimeZone(tzOffset * 60000, "LLL");		if (explicitTimeZone)			calendar = new GregorianCalendar(zone);		else {			calendar = new GregorianCalendar();			tzOffset =				(calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET))					/ 60000;		}		calendar.setLenient(false);		calendar.set(year, month - 1, day);		if (explicitTimeZone)			calendar.set(Calendar.ZONE_OFFSET, tzOffset * 60000);		System.out.println(calendar.getTimeZone().getDisplayName());		try {			date = calendar.getTime();		} catch (Exception e) {			throw new XPathException(				"Type error: string " + dateString + " cannot be cast into an xs:date");		}	}