Code example for Time

Methods: compare, normalize, set

0
	 * Computes the julian day for the given timestamp while taking into 
	 * consideration Zeo's rules for gauging a night of sleep between the 12am 
	 * to 6am time window. 
	 */ 
	public static int getZeoJulianDay(final long timestamp) {
		final Time startTime = new Time();
		startTime.set(timestamp);
		int julianDay = Time.getJulianDay(startTime.normalize(true),
				startTime.gmtoff);
 
		// Begin process of determining if this record was from 12am to 6am. 
		final Time midnight = new Time();
		midnight.set(startTime);
		midnight.hour = 0;
		midnight.minute = 0;
		midnight.second = 0;
		midnight.normalize(true);
 
		final Time morning = new Time();
		morning.set(midnight);
		morning.hour = 6;
		morning.normalize(true);
 
		if (Time.compare(startTime, midnight) >= 0
				&& Time.compare(startTime, morning) <= 0) {
			--julianDay;
		} 
 
		return julianDay;
	}