public TimeValue(String timeValue) throws XPathException { Perl5Util util = new Perl5Util(); if (!util.match(regex, timeValue)) throw new XPathException( "Type error: string " + timeValue + " cannot be cast into an xs:time"); String part = util.group(1); int hour = Integer.parseInt(part); part = util.group(2); int minutes = Integer.parseInt(part); part = util.group(3); int seconds = Integer.parseInt(part); part = util.group(5); int millis = 0; if (part != null) { if (part.length() < 3) part += "00"; if (part.length() > 3) part = part.substring(0, 3); millis = Integer.parseInt(part); } part = util.group(6); if (part != null && part.length() > 0 && (!part.equals("Z"))) { if (!util.match(tzre, part)) throw new XPathException("Type error: error in  timezone: " + part); explicitTimeZone = true; part = util.group(2); tzOffset = Integer.parseInt(part) * 60; part = util.group(3); if (part != null) { int tzminute = Integer.parseInt(part); tzOffset += tzminute; } part = util.group(1); if (part.equals("-")) tzOffset *= -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(Calendar.HOUR_OF_DAY, hour); calendar.set(Calendar.MINUTE, minutes); calendar.set(Calendar.SECOND, seconds); calendar.set(Calendar.MILLISECOND, millis); if (explicitTimeZone) calendar.set(Calendar.ZONE_OFFSET, tzOffset * 60000); try { date = calendar.getTime(); } catch (Exception e) { throw new XPathException( "Type error: string " + timeValue + " cannot be cast into an xs:time"); }
public TimeValue() { calendar = new GregorianCalendar(); tzOffset = (calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET)) / 60000; calendar.set(Calendar.YEAR, 2000); calendar.set(Calendar.MONTH, 0); calendar.set(Calendar.DATE, 1); date = calendar.getTime();
	public TimeValue(String timeValue) throws XPathException {		Perl5Util util = new Perl5Util();		if (!util.match(regex, timeValue))			throw new XPathException(				"Type error: string " + timeValue + " cannot be cast into an xs:time");		String part = util.group(1);		int hour = Integer.parseInt(part);		part = util.group(2);		int minutes = Integer.parseInt(part);		part = util.group(3);		int seconds = Integer.parseInt(part);		part = util.group(5);		int millis = 0;		if (part != null) {			if (part.length() < 3)				part += "00";			if (part.length() > 3)				part = part.substring(0, 3);			millis = Integer.parseInt(part);		}		part = util.group(6);		if (part != null && part.length() > 0 && (!part.equals("Z"))) {			if (!util.match(tzre, part))				throw new XPathException("Type error: error in  timezone: " + part);			explicitTimeZone = true;			part = util.group(2);			tzOffset = Integer.parseInt(part) * 60;			part = util.group(3);			if (part != null) {				int tzminute = Integer.parseInt(part);				tzOffset += tzminute;			}			part = util.group(1);			if (part.equals("-"))				tzOffset *= -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(Calendar.HOUR_OF_DAY, hour);		calendar.set(Calendar.MINUTE, minutes);		calendar.set(Calendar.SECOND, seconds);		calendar.set(Calendar.MILLISECOND, millis);		if (explicitTimeZone)			calendar.set(Calendar.ZONE_OFFSET, tzOffset * 60000);		try {			date = calendar.getTime();		} catch (Exception e) {			throw new XPathException(				"Type error: string " + timeValue + " cannot be cast into an xs:time");		}	}