Java Date Before isBeforeCommonEra(Date date)

Here you can find the source of isBeforeCommonEra(Date date)

Description

Returns true if the date is before the common era.

License

Open Source License

Declaration

private static boolean isBeforeCommonEra(Date date) 

Method Source Code

//package com.java2s;

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.TimeZone;

public class Main {
    /**/*www.  j  a  va2 s  .com*/
     * The UTC time zone.
     */
    private static final ThreadLocal<TimeZone> UTC_TZ = new ThreadLocal<TimeZone>() {
        @Override
        protected TimeZone initialValue() {
            return TimeZone.getTimeZone("UTC");
        }
    };

    /**
     * Returns true if the date is before the common era.
     */
    private static boolean isBeforeCommonEra(Date date) {
        Calendar cal = getCalendarUTC();
        cal.setTime(date);
        return cal.get(Calendar.ERA) == GregorianCalendar.BC;
    }

    /**
     * Get a UTC calendar with Locale US.
     */
    private static Calendar getCalendarUTC() {
        return new GregorianCalendar(UTC_TZ.get(), Locale.US);
    }
}

Related

  1. isAtLeastOneDayBefore(Date daybefore, Date dayafter)
  2. isBefore(Date date)
  3. isBefore(Date date1, Date date2)
  4. isBefore2015(Date date)
  5. isBefore_day(Date time1, Date time2, int days)
  6. isBeforeDate(long time1, long time2)
  7. isBeforeEndOfDate(Date subject, Date predicate)
  8. isDataBeforeData2TruncByDay(Date data1, Date data2)
  9. isDateBeforeCurrentDate(Date date)