// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.util.*;

public class TimeFun {
    // sligtly modified
    public static Date calc1(long v) {
        long tmp = v;
        Calendar c = new GregorianCalendar(1900, Calendar.JANUARY, 1, 0, 0, 0);
        while (tmp > Integer.MAX_VALUE) {
            c.add(Calendar.SECOND, Integer.MAX_VALUE);
            tmp -= Integer.MAX_VALUE;
        }
        c.add(Calendar.SECOND, (int) tmp);
        return c.getTime();
    }
    // heavily modified
    private static final Calendar c1900 = new GregorianCalendar(1900, Calendar.JANUARY, 1, 0, 0, 0);
    public static Date calc2(long v) {
        return new Date(c1900.getTimeInMillis() + 1000 * v);
    }
    public static void main(String[] args) {
        System.out.println(calc1(123456789));
        System.out.println(calc2(123456789));
    }
}
