Take a universal time between 0 and 24 and return a triple [hours, minutes, seconds]. - Android java.util

Android examples for java.util:Second

Description

Take a universal time between 0 and 24 and return a triple [hours, minutes, seconds].

Demo Code

// Licensed under the Apache License, Version 2.0 (the "License");
//package com.java2s;

public class Main {
    /**// ww  w . j  av a2s  .  c  om
     * Take a universal time between 0 and 24 and return a triple
     * [hours, minutes, seconds].
     * 
     * @param ut Universal time - presumed to be between 0 and 24.
     * @return [hours, minutes, seconds]
     */
    public static int[] clockTimeFromHrs(double ut) {
        int[] hms = new int[3];
        hms[0] = (int) Math.floor(ut);
        double remainderMins = 60 * (ut - hms[0]);
        hms[1] = (int) Math.floor(remainderMins);
        hms[2] = (int) Math.floor(remainderMins - hms[1]);
        return hms;
    }
}

Related Tutorials