ghostrider
ghostrider

Reputation: 2238

Julian Day vs the Date object to get the present day

While referring to a particular course I came across the following code to retrieve the current day:

int julianStartDay = Time.getJulianDay(System.currentTimeMillis(),   dayTime.gmtoff);
long dateTime;
dateTime = dayTime.setJulianDay(julianStartDay);
day = getReadableDateString(dateTime);

     private String getReadableDateString(long time){
          SimpleDateFormat shortenedDateFormat = new SimpleDateFormat("E MMM d");
            return shortenedDateFormat.format(time);
        }

My doubt is why are we using this julian method instead of just directly extracting the day from the Date class object which gives the current date and time.

Upvotes: 0

Views: 476

Answers (1)

super_aardvark
super_aardvark

Reputation: 1855

Is your application related to the Eastern Orthodox religious calendar? As far as I'm aware, that's the only place the Julian calendar is still in use.

The Java Date and Calendar classes use the Gregorian calendar by default. (Calendar.getInstance methods return a GregorianCalendar object unless one of two specific locales is specified.) If your application needs to use the Julian calendar instead, that would explain this implementation.

Upvotes: 2

Related Questions