org.kuali.common.util
Class SimpleFormatter

java.lang.Object
  extended by org.kuali.common.util.SimpleFormatter

public class SimpleFormatter
extends Object

Format time, bytes, counts, dates, and transfer rates into human friendly form

Since:
May 27, 2010 6:46:17 PM
Author:
Jeff Caddel

Constructor Summary
SimpleFormatter()
           
 
Method Summary
 String getCount(long count)
          Return a formatted count
 NumberFormat getCountFormatter()
           
 String getDate(Date date)
          Return a formatted date
 String getDate(long millis)
          Return a formatted date
 String getFormattedSize(long bytes, Size size)
           
 NumberFormat getLargeSizeFormatter()
           
 String getRate(long millis, long bytes)
          Given a number of bytes and the number of milliseconds it took to transfer that number of bytes, return bytes/s, KB/s, MB/s, GB/s, TB/s, PB/s, or EB/s as appropriate
 NumberFormat getRateFormatter()
           
 String getSize(long bytes)
          Given a number of bytes return bytes, kilobytes, megabytes, gigabytes, terabytes, petabytes, or exabytes as appropriate.
 String getSize(long bytes, Size unitOfMeasure)
          Given a number of bytes return a string formatted into the unit of measure indicated
 Size getSizeEnum(double bytes)
           
 NumberFormat getSizeFormatter()
           
 String getTime(long millis)
          Given milliseconds, return milliseconds, seconds, minutes, hours, days, years, decades, or centuries as appropriate.
 NumberFormat getTimeFormatter()
           
 Date parseDate(String date)
          Parse a date from the string.
 void setCountFormatter(NumberFormat countFormatter)
           
 void setLargeSizeFormatter(NumberFormat sizeFormatter)
           
 void setRateFormatter(NumberFormat rateFormatter)
           
 void setSizeFormatter(NumberFormat smallSizeFormatter)
           
 void setTimeFormatter(NumberFormat timeFormatter)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleFormatter

public SimpleFormatter()
Method Detail

parseDate

public Date parseDate(String date)
Parse a date from the string. The string must be in the same format returned by the getDate() methods


getDate

public String getDate(long millis)
Return a formatted date


getDate

public String getDate(Date date)
Return a formatted date


getRate

public String getRate(long millis,
                      long bytes)
Given a number of bytes and the number of milliseconds it took to transfer that number of bytes, return bytes/s, KB/s, MB/s, GB/s, TB/s, PB/s, or EB/s as appropriate


getCount

public String getCount(long count)
Return a formatted count


getTime

public String getTime(long millis)
Given milliseconds, return milliseconds, seconds, minutes, hours, days, years, decades, or centuries as appropriate. Note that years, decades, and centuries are approximations since the logic always assumes there are exactly 365 days per year.


getSize

public String getSize(long bytes)
Given a number of bytes return bytes, kilobytes, megabytes, gigabytes, terabytes, petabytes, or exabytes as appropriate.


getSize

public String getSize(long bytes,
                      Size unitOfMeasure)
Given a number of bytes return a string formatted into the unit of measure indicated


getFormattedSize

public String getFormattedSize(long bytes,
                               Size size)

getSizeEnum

public Size getSizeEnum(double bytes)

getLargeSizeFormatter

public NumberFormat getLargeSizeFormatter()

setLargeSizeFormatter

public void setLargeSizeFormatter(NumberFormat sizeFormatter)

getTimeFormatter

public NumberFormat getTimeFormatter()

setTimeFormatter

public void setTimeFormatter(NumberFormat timeFormatter)

getRateFormatter

public NumberFormat getRateFormatter()

setRateFormatter

public void setRateFormatter(NumberFormat rateFormatter)

getSizeFormatter

public NumberFormat getSizeFormatter()

setSizeFormatter

public void setSizeFormatter(NumberFormat smallSizeFormatter)

getCountFormatter

public NumberFormat getCountFormatter()

setCountFormatter

public void setCountFormatter(NumberFormat countFormatter)


Copyright © 2010-2013 The Kuali Foundation. All Rights Reserved.