gavenkoa
gavenkoa

Reputation: 48753

Look for standard Java auxiliary class or interface which hold datetime constants

There are many definitions of constants like:

public static final long MS_IN_YEAR = 1000L * 3600L * 365L;
public static final int SEC_IN_DAY = 3600;

Are there any standard class, which already hold these constants?

Recently I found bug in own constant definition. I like to avoid such bugs at all...

UPDATE Also I think that standard definitions provide consistent short names for constants so you shouldn't invent own!

Upvotes: 1

Views: 161

Answers (1)

arshajii
arshajii

Reputation: 129507

As far as I know, there's nothing like this in the standard JDK classes. There are, however, similar fields in the DateTimeConstants class of Joda-Time.

There's definitely SECONDS_PER_DAY, but there doesn't seem to be one specifically for millis in a year. You could just multiply MILLIS_PER_DAY by 365.

Upvotes: 3

Related Questions