package com.db4o.lib;

import java.util.GregorianCalendar;

public class Time
{
	int i_hours;
	int i_minutes;
	int i_seconds;
	
	public Time(){
		GregorianCalendar l_Cal = new GregorianCalendar();				
		i_hours = l_Cal.get(GregorianCalendar.HOUR_OF_DAY);
		i_minutes = l_Cal.get(GregorianCalendar.MINUTE);
		i_seconds = l_Cal.get(GregorianCalendar.SECOND);
	}
	
	public Time(int a_hours, int a_minutes, int a_seconds)
		throws Exception
	{
		i_hours = a_hours;
		i_minutes = a_minutes;
		i_seconds = a_seconds;
		validate();
	}
	
	public int getHours(){
		return i_hours;
	}
	
	public int getMinutes(){
		return i_minutes;
	}
	
	public int getSeconds(){
		return i_seconds;
	}
	
	private void validate() throws Exception {
		if (i_hours < 0) throw new Exception("hours < 0");
		if (i_hours > 24) throw new Exception("hours > 24");
		if (i_minutes < 0) throw new Exception("minutes < 0");
		if (i_minutes > 59) throw new Exception("minutes > 59");
		if (i_seconds < 0) throw new Exception("seconds < 0");
		if (i_seconds > 59) throw new Exception("seconds > 59");
		
	}
}
