package com.webcodepro.shrinkit; import java.io.IOException; import java.io.InputStream; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; /** * Apple IIgs Toolbox TimeRec object. * * @author robgreene@users.sourceforge.net */ public class TimeRec { private static final int SECOND = 0; private static final int MINUTE = 1; private static final int HOUR = 2; private static final int YEAR = 3; private static final int DAY = 4; private static final int MONTH = 5; private static final int WEEKDAY = 7; private static final int LENGTH = 8; private byte[] data = null; /** * Construct a TimeRec with the current date. */ public TimeRec() { this(new Date()); } /** * Construct a TimeRec with the specified date. You may pass in a null for a null date (all 0x00's). */ public TimeRec(Date date) { setDate(date); } /** * Construct a TimeRec from the given LENGTH byte array. */ public TimeRec(byte[] bytes, int offset) { if (bytes == null || bytes.length - offset < LENGTH) { throw new IllegalArgumentException("TimeRec requires a " + LENGTH + " byte array."); } //data = Arrays.copyOfRange(bytes, offset, LENGTH); data = new byte[LENGTH]; System.arraycopy(bytes, offset, data, 0, LENGTH); } /** * Construct a TimeRec from the InputStream. */ public TimeRec(InputStream inputStream) throws IOException { data = new byte[LENGTH]; for (int i=0; i