Java Second Get getSeconds(double t)

Here you can find the source of getSeconds(double t)

Description

Returns full number of seconds for given double time value.

License

Open Source License

Parameter

Parameter Description
t time value in hours.

Return

double value of seconds.

Declaration

public static double getSeconds(double t) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*w w  w  . j  av  a  2 s  .  c  o  m*/
     * Returns full number of seconds for given <code>double</code> time value.
     * @param t time value in hours.
     * @return <code>double</code> value of seconds. 
     */
    public static double getSeconds(double t) {
        double tt = (t - getHours(t)) * 60;
        tt = (tt - getMinutes(t)) * 60;
        return Math.min(tt, 59.9);
    }

    /**
     * Returns full number of hours for given <code>double</code> time value.
     * @param t time value in hours.
     * @return <code>int</code> value of hours. 
     */
    public static int getHours(double t) {
        return (int) Math.floor(t);
    }

    /**
     * Returns full number of minutes for given <code>double</code> time value.
     * @param t time value in hours.
     * @return <code>int</code> value of minutes. 
     */
    public static int getMinutes(double t) {
        double tt = (t - getHours(t)) * 60;
        return (int) Math.floor(tt);
    }
}

Related

  1. getSecondRDNValue(String dn)
  2. getSecondRulePart()
  3. getSeconds()
  4. getSeconds(double coordinate)
  5. getSeconds(double seconds)
  6. getSeconds(final double DEC_DEG)
  7. getSeconds(int minutes)
  8. getSeconds(String s)
  9. getSeconds(String time)