com.neeve.util
Class UtlUnit

java.lang.Object
  extended by com.neeve.util.UtlUnit

public class UtlUnit
extends Object

Utilities for unit conversion.

This class IS NOT intended to be used by end users.


Nested Class Summary
static class UtlUnit.Bytes
          Represents a unit represented in bytes.
 
Constructor Summary
UtlUnit()
           
 
Method Summary
static String formatDuration(long duration, TimeUnit unit)
          Converts a duration in nanoseconds to a human readable string.
static String readableBytesSize(long size)
          Returns a readable string for the given number of bytes.
static long toNumBytes(String size)
          Converts a string to a number of bytes.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UtlUnit

public UtlUnit()
Method Detail

readableBytesSize

public static String readableBytesSize(long size)
Returns a readable string for the given number of bytes.

Parameters:
size - The size in bytes to convert.
Returns:
A readable string for the given number of bytes.

toNumBytes

public static long toNumBytes(String size)
Converts a string to a number of bytes.

Parameters:
size - The size in bytes in String form.
Returns:
The number of bytes.

formatDuration

public static final String formatDuration(long duration,
                                          TimeUnit unit)
Converts a duration in nanoseconds to a human readable string.

The conversion displays the duration in the largest significant unit of days,hours,minutes,seconds,millis,micros, or nanos to 1 decimal point.

Parameters:
duration - The duration to format.
unit - The time unit of the duration.
Returns:
The formatted duration.


Copyright © 2016 Neeve Research, LLC. All Rights Reserved.