net.luniks.text
Class TimeFormat

java.lang.Object
  extended bynet.luniks.text.TimeFormat

public class TimeFormat
extends java.lang.Object

Class to convert Strings representing a time to milliseconds and to format seconds as String representing a time.


Field Summary
private static java.text.DecimalFormat decimalFormat
           
private static java.text.DecimalFormat numberFormat
           
 
Constructor Summary
TimeFormat()
           
 
Method Summary
 java.lang.String format(int seconds)
          Formats the seconds given as int argument to a String representing a time in the format "HH:mm:ss"
 java.lang.String format(long millis)
          Formats the milliseconds given as long argument to a String representing a time in the format "HH:mm:ss,SSS"
static void main(java.lang.String[] args)
          For testing
 long parse(java.lang.String time)
          Converts a String representing a time in the format "HH:mm:ss,SSS" to milliseconds.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

decimalFormat

private static final java.text.DecimalFormat decimalFormat

numberFormat

private static final java.text.DecimalFormat numberFormat
Constructor Detail

TimeFormat

public TimeFormat()
Method Detail

parse

public long parse(java.lang.String time)
           throws java.text.ParseException
Converts a String representing a time in the format "HH:mm:ss,SSS" to milliseconds. The hours, minutes and milliseconds are optional.

Parameters:
time - String representing a time
Returns:
the time in milliseconds
Throws:
java.text.ParseException

format

public java.lang.String format(int seconds)
Formats the seconds given as int argument to a String representing a time in the format "HH:mm:ss"

Parameters:
seconds - the seconds to format
Returns:
formatted time, "OVERFLOW" if the argument type's minimum or maximum value has been exceeded

format

public java.lang.String format(long millis)
Formats the milliseconds given as long argument to a String representing a time in the format "HH:mm:ss,SSS"

Parameters:
millis - the milliseconds to format
Returns:
formatted time, "OVERFLOW" if the argument type's minimum or maximum value has been exceeded

main

public static void main(java.lang.String[] args)
For testing



Copyright (c) 2004, 2005 Torsten Römer, dode@luniks.net