Documentation of 'com.mhuss.AstroLib.AstroDate' Java class
AstroDate
com.mhuss.AstroLib

Class AstroDate



  • public class AstroDate
    extends java.lang.Object
    A support class for DateOps.

    This class stores a date/time value at a precision of one second. This date/time can be specified using either the Gregorian Calendar (by default) or the Julian Calendar.

    It also supports conversions to and from the Julian Day number.

    • Constructor Summary

      Constructors 
      Constructor and Description
      AstroDate()
      Default constructor = epoch J2000 (noon on 1/1/2000)
      AstroDate(double jd)
      Julian Day constructor.
      AstroDate(int day, int month, int year)
      Day, Month, Year constructor (time defaults to 00:00:00 = midnight)
      AstroDate(int day, int month, int year, double dayFraction)
      Day, Month, Year + fraction of a day constructor
      AstroDate(int day, int month, int year, int seconds)
      Literal (member by member) constructor
      AstroDate(int day, int month, int year, int hour, int min, int sec)
      Explicit day, month, year, hour, minute, and second constructor
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      int day()
      Get the day.
      int hour()
      Get the Hour.
      int hourRound()
      Get the rounded hour.
      double jd()
      Convert this instance of AstroDate to a Julian Day.
      static double jd(AstroDate ad)
      Convert an AstroDate to a Julian Day.
      static double jd(AstroDate ad, boolean julian)
      Convert an AstroDate to a Julian Day.
      double jd(boolean julian)
      Convert this instance of AstroDate to a Julian Day.
      static void main(java.lang.String[] args)
      (for unit testing only)
      int minute()
      Get the minute.
      int minuteRound()
      Get the rounded minute.
      int month()
      Get the month.
      int second()
      Get the second.
      java.util.GregorianCalendar toGCalendar()
      Convert this AstroDate instance to a GregorianCalendar.
      java.lang.String toMinString()
      Convert this AstroDate instance to a String, formatted to the minute.
      java.lang.String toMinStringTZ()
      Convert this AstroDate instance to a String formatted to the minute, with Time Zone indicator.
      java.lang.String toString()
      Convert this AstroDate instance to a String.
      java.lang.String toStringTZ()
      Convert this AstroDate instance to a String, with Time Zone indicator.
      int year()
      Get the year.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • AstroDate

        public AstroDate()
        Default constructor = epoch J2000 (noon on 1/1/2000)
      • AstroDate

        public AstroDate(int day,
                         int month,
                         int year,
                         int seconds)
        Literal (member by member) constructor
        Parameters:
        day - Day of the month (1...31)
        month - Month of the year (1..12)
        year - Year
        seconds - Time in seconds past midnight. This must be in the range from 0 to Astro.SECONDS_PER_DAY-1.
      • AstroDate

        public AstroDate(int day,
                         int month,
                         int year,
                         int hour,
                         int min,
                         int sec)
        Explicit day, month, year, hour, minute, and second constructor
        Parameters:
        day - Day of the month (1...31)
        month - Month of the year (1..12)
        year - Year
        hour - Hour of the day (0...23)
        min - Minute of the hour (0...59)
        sec - Second of the minute (0...59)
      • AstroDate

        public AstroDate(int day,
                         int month,
                         int year)
        Day, Month, Year constructor (time defaults to 00:00:00 = midnight)
        Parameters:
        day - Day of the month (1...31)
        month - Month of the year (1..12)
        year - Year
      • AstroDate

        public AstroDate(int day,
                         int month,
                         int year,
                         double dayFraction)
        Day, Month, Year + fraction of a day constructor
        Parameters:
        day - Day of the month
        month - Month of the year
        year - Year
        dayFraction - Fraction of the day
        This must be greater than or equal to 0.0 and less than 1.0.
      • AstroDate

        public AstroDate(double jd)
        Julian Day constructor.
        Parameters:
        jd - Julian day number
    • Method Detail

      • jd

        public static double jd(AstroDate ad,
                                boolean julian)
        Convert an AstroDate to a Julian Day.
        Parameters:
        ad - The date to convert
        julian - true = Julian calendar, else Gregorian
        Returns:
        The Julian Day that corresponds to the specified AstroDate
      • jd

        public static double jd(AstroDate ad)
        Convert an AstroDate to a Julian Day.
        Assumes the AstroDate is specified using the Gregorian calendar.
        Parameters:
        ad - The date to convert
        Returns:
        The Julian Day that corresponds to the specified AstroDate
      • jd

        public double jd(boolean julian)
        Convert this instance of AstroDate to a Julian Day.
        Parameters:
        julian - true = Julian calendar, else Gregorian
        Returns:
        The Julian Day that corresponds to this AstroDate instance
      • jd

        public double jd()
        Convert this instance of AstroDate to a Julian Day.
        Assumes the AstroDate is specified using the Gregorian calendar.
        Returns:
        The Julian Day that corresponds to this AstroDate instance
      • year

        public int year()
        Get the year.
        Returns:
        The year part of this instance of AstroDate
      • month

        public int month()
        Get the month.
        Returns:
        The month part of this instance of AstroDate (1..12)
      • day

        public int day()
        Get the day.
        Returns:
        The day part of this instance of AstroDate (1..31)
      • hour

        public int hour()
        Get the Hour.
        This function truncates, and does not round up to nearest hour. For example, this function will return '1' at all times from 01:00:00 to 01:59:59 inclusive.
        Returns:
        The hour of the day for this instance of AstroDate, not rounded
      • hourRound

        public int hourRound()
        Get the rounded hour.
        Returns the hour of the day rounded to nearest hour. For example, this function will return '1' at times 01:00:00 to 01:29:59, and '2' at times 01:30:00 to 01:59:59.
        Returns:
        The hour of the day for this instance of AstroDate, rounded to the nearest hour.
      • minute

        public int minute()
        Get the minute.
        This function truncates, and does not round up to nearest minute. For example, this function will return 20 at all times from 1:20:00 to 1:20:59 inclusive.
        Returns:
        The minute of the hour for this instance of AstroDate, not rounded.
      • minuteRound

        public int minuteRound()
        Get the rounded minute.
        Returns the minute of the hour for this instance of AstroDate, rounded to nearest minute. For example, this function will return 20 at times 1:20:00 to 1:20:29, and 21 at times 1:20:30 to 1:20:59.
        Returns:
        The minute of the hour for this instance of AstroDate, rounded to the nearest minute.
      • second

        public int second()
        Get the second.
        Returns:
        The second of the minute for this instance of AstroDate.
      • toGCalendar

        public java.util.GregorianCalendar toGCalendar()
        Convert this AstroDate instance to a GregorianCalendar.
        Returns:
        An instance of java.util.GregorianCalendar built using this instance of AstroDate.
      • toMinString

        public java.lang.String toMinString()
        Convert this AstroDate instance to a String, formatted to the minute. This function rounds the exact time to the nearest minute.

        The format of the returned string is YYYY-MM-DD hh:mm.

        Returns:
        A formatted date/time String
      • toMinStringTZ

        public java.lang.String toMinStringTZ()
        Convert this AstroDate instance to a String formatted to the minute, with Time Zone indicator.
        Rounds the time to the nearest minute.

        The format of the returned string is YYYY-MM-DD hh:mm TZ, where TZ is a locale-specific timezone name (e.g., "EST").

        Returns:
        A formatted date/time String
      • toString

        public java.lang.String toString()
        Convert this AstroDate instance to a String.

        The format of the returned string is YYYY-MM-DD hh:mm:ss.

        Overrides:
        toString in class java.lang.Object
        Returns:
        A formatted date/time String
      • toStringTZ

        public java.lang.String toStringTZ()
        Convert this AstroDate instance to a String, with Time Zone indicator.

        The format of the returned string is YYYY-MM-DD hh:mm:ss TZ, where TZ is a locale-specific timezone name (e.g., "EST")

        Returns:
        A formatted date/time String
      • main

        public static void main(java.lang.String[] args)
        (for unit testing only)

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.