BigDateExperiment.javaFrom WikiJava
This is an experiment I did some time ago, I was curious about the biggest date which is possible to represent in Java using the famous time in milliseconds since the great midnight of the new years eve of 1970 and the most far date in the future representable with a Calendar object. It's been an interesting findings. I hope to see the new millennium bug for the end of the milliseconds in a long.
the code
package org.wikijava.time; import java.io.PrintStream; import java.util.Calendar; import java.util.Date; /** * * prints out the most far date in the future representable with a long in * milliseconds * * @author Giulio */ public class BigDateExperiment { public BigDateExperiment() { } public static void main(String args[]) { Date date = new Date(Long.MAX_VALUE); System.out.println("the biggest date representable in Java " + "using a java.util.Date: " + date); Calendar calendar = Calendar.getInstance(); System.out.println((new StringBuilder( "the biggest date representable in Java " + "using java.util.Calendar: ")).append( calendar.getMaximum(Calendar.YEAR)).append("-").append( calendar.getMaximum(Calendar.MONTH)).append("-").append( calendar.getMaximum(Calendar.DAY_OF_MONTH)).toString()); } } |
