Java Second Convert convertToTenthsOfASecond(long epochSeconds, int nanos)

Here you can find the source of convertToTenthsOfASecond(long epochSeconds, int nanos)

Description

Event rate rate limiting uses a tenths of a seconds units to cater to monitor intervals of 0.1 seconds, 0.5 seconds etc..

License

Open Source License

Parameter

Parameter Description
epochSeconds  
nanos  

Exception

Parameter Description
NumberFormatException 

Return

TenthsOfASecond  

Declaration

public static long convertToTenthsOfASecond(long epochSeconds, int nanos) throws NumberFormatException 

Method Source Code

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

public class Main {
    /**/*from   ww  w  . j  a v  a2 s. co m*/
     * Event rate rate limiting uses a tenths of a seconds units to cater to monitor intervals of 0.1 seconds, 0.5 seconds etc.. 
     * This converts a epochSeconds+nanos to time in terms of tenths of a second.
     * @param epochSeconds  
     * @param nanos  
     * @return TenthsOfASecond   
     * @throws NumberFormatException    
     */
    public static long convertToTenthsOfASecond(long epochSeconds, int nanos) throws NumberFormatException {
        int tenthsPieceOfNanos = (nanos / (100000000));
        if (tenthsPieceOfNanos > 9) {
            throw new NumberFormatException(
                    "Tenths of nanos cannot be greater than 9 but this is " + tenthsPieceOfNanos);
        }
        return epochSeconds * 10 + tenthsPieceOfNanos;
    }
}

Related

  1. convertTimemilisecondsToHours(long time)
  2. convertTimeSecondsToHMS(long longSecs)
  3. convertTimeToSeconds(String a_time)
  4. convertToSeconds(String time)
  5. convertToSeconds(String timeStr)
  6. secondConvertToString(final long spentSeconds)
  7. seconds2microseconds(double secs)
  8. seconds2String(long seconds)
  9. seconds2time(long seconds)