Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
395 views
in Technique[技术] by (71.8m points)

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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));

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...