Search code examples
javacalendargregorian-calendar

Java: What/where are the maximum and minimum values of a GregorianCalendar?


What are the maximum and minimum values of a GregorianCalendar?

Are they in a constant like Integer.MAX_VALUE, or maybe GregorianCalendar.get(BLAH)?

In a nutshell, how can I create a GregorianCalendar instance with min/max value?


Solution

  • This should work:

    GregorianCalendar maxgc = new GregorianCalendar();
    maxgc.setTime(new Date(Long.MAX_VALUE));
    
    GregorianCalendar mingc = new GregorianCalendar();
    mingc.setTime(new Date(Long.MIN_VALUE));