Java Milliseconds marsTimeFromElapsedMillis(long elapsedMillis, int[] marsTime)

Here you can find the source of marsTimeFromElapsedMillis(long elapsedMillis, int[] marsTime)

Description

Calculate the local Mars time from the number of milliseconds since the start of Sol 1.

License

Open Source License

Declaration

private static void marsTimeFromElapsedMillis(long elapsedMillis,
        int[] marsTime) 

Method Source Code

//package com.java2s;
/** /* ww  w  .  j  av  a  2  s . com*/
 *  Midnight Mars Browser - http://midnightmarsbrowser.blogspot.com
 *  Copyright (c) 2005 by Michael R. Howard
 *
 *  Midnight Mars Browser is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 * 
 *  Midnight Mars Browser is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Midnight Mars Browser; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 * 
 */

public class Main {
    /**
     * Calculate the local Mars time from the number of milliseconds since 
     * the start of Sol 1.
     */
    private static void marsTimeFromElapsedMillis(long elapsedMillis,
            int[] marsTime) {
        double marsDaySecs = (double) 35.244 + (double) 24 * 60 * 60 + 39
                * 60;
        double solDouble = ((double) (elapsedMillis / 1000)) / marsDaySecs;
        double hourDouble = (solDouble - ((long) solDouble)) * 24;
        double minuteDouble = (hourDouble - ((long) hourDouble)) * 60;
        double secondDouble = (minuteDouble - ((long) minuteDouble)) * 60;

        int sol = (int) (solDouble) + 1;
        int hour = (int) (hourDouble);
        int minute = (int) (minuteDouble);
        int second = (int) (secondDouble);
        marsTime[0] = sol;
        marsTime[1] = hour;
        marsTime[2] = minute;
        marsTime[3] = second;
    }
}

Related

  1. hasExpiredMillis(long now, long eventTime, long timeBuffer)
  2. hhmmssToMillis(String text)
  3. humanDateToMillisecondsWithoutException(String date)
  4. isSameSecondOfMillis(final long ms1, final long ms2)
  5. longToDate(long millis)
  6. megaCyclesToMilliseconds(long megaCycles)
  7. microsToMillis(long micros)
  8. microsToMillis(long sec, long usec)
  9. milliDate(String date)