Android Long to Date Convert toJulianDay(long epochMillis)

Here you can find the source of toJulianDay(long epochMillis)

Description

Calculates the astronomical Julian Day for an instant.

License

Apache License

Parameter

Parameter Description
epochMillis the epoch millis from 1970-01-01Z

Return

the astronomical Julian Day represented by the specified instant

Declaration

public static final double toJulianDay(long epochMillis) 

Method Source Code

//package com.java2s;
/*/*w ww  . j a va2 s  .c o m*/
 *  Copyright 2001-2012 Stephen Colebourne
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

public class Main {
    /**
     * Calculates the astronomical Julian Day for an instant.
     * <p>
     * The <a href="http://en.wikipedia.org/wiki/Julian_day">Julian day</a> is a well-known
     * system of time measurement for scientific use by the astronomy community.
     * It expresses the interval of time in days and fractions of a day since
     * January 1, 4713 BC (Julian) Greenwich noon.
     * <p>
     * Each day starts at midday (not midnight) and time is expressed as a fraction.
     * Thus the fraction 0.25 is 18:00. equal to one quarter of the day from midday to midday.
     * <p>
     * Note that this method has nothing to do with the day-of-year.
     * 
     * @param epochMillis  the epoch millis from 1970-01-01Z
     * @return the astronomical Julian Day represented by the specified instant
     * @since 2.2
     */
    public static final double toJulianDay(long epochMillis) {
        // useful links
        // http://en.wikipedia.org/wiki/Julian_day#cite_note-13 - Wikipedia
        // http://aa.usno.navy.mil/data/docs/JulianDate.php" - USNO
        // http://users.zoominternet.net/~matto/Java/Julian%20Date%20Converter.htm - Julian Date Converter by Matt Oltersdorf
        // http://ssd.jpl.nasa.gov/tc.cgi#top - CalTech
        double epochDay = epochMillis / 86400000d;
        return epochDay + 2440587.5d;
    }
}

Related

  1. timestampToIso8601Str(long timestamp)
  2. toCalendar(long hour)
  3. toDateString(long seconds)
  4. toFullDate(long timestamp)
  5. toIso8601(long date, boolean utc)
  6. toJulianDayNumber(long epochMillis)
  7. toString(Long datetime)
  8. toTimeString(long milliseconds)
  9. stringForTime(long timeMs)