gcspy.utils
Class Utils

java.lang.Object
  extended by gcspy.utils.Utils

public class Utils
extends java.lang.Object

General utilities

Author:
Tony Printezis

Constructor Summary
Utils()
           
 
Method Summary
static int countChars(java.lang.String str, char c)
          Count the number of occurrences of a character in a string
static int countLines(java.lang.String text)
          Count the number of lines in a string
static java.lang.String formatDate(java.util.Date date)
          Format as a date
static java.lang.String formatDateTime(java.util.Date date)
          Format as a time and date
static java.lang.String formatPercentage(double perc)
          Format as a percentage
static java.lang.String formatSize(double size)
          Format as a size
static java.lang.String formatSize(long size)
          Format as a size
static java.lang.String formatTime(java.util.Date date)
          Format as a time
static java.lang.String padLeft(java.lang.String str, int len)
          Pad a string to the left
static java.lang.String padRight(java.lang.String str, int len)
          Pad a string to the right
static void sleep(long millis)
          Sleep for a period
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utils

public Utils()
Method Detail

formatPercentage

public static java.lang.String formatPercentage(double perc)
Format as a percentage

Parameters:
perc - the value to format
Returns:
the value as a percentage

formatSize

public static java.lang.String formatSize(long size)
Format as a size

Parameters:
size - the value to format
Returns:
the formatted value

formatSize

public static java.lang.String formatSize(double size)
Format as a size

Parameters:
size - the value to format
Returns:
the formatted value

formatDate

public static java.lang.String formatDate(java.util.Date date)
Format as a date

Parameters:
date - The date
Returns:
the formatted date

formatTime

public static java.lang.String formatTime(java.util.Date date)
Format as a time

Parameters:
date - the time to format
Returns:
the formatted time

formatDateTime

public static java.lang.String formatDateTime(java.util.Date date)
Format as a time and date

Parameters:
date - the date to format
Returns:
the formatted time and date

padLeft

public static java.lang.String padLeft(java.lang.String str,
                                       int len)
Pad a string to the left

Parameters:
str - the string
len - the space in which to place the string
Returns:
the padded string

padRight

public static java.lang.String padRight(java.lang.String str,
                                        int len)
Pad a string to the right

Parameters:
str - the string
len - the space in which to place the string
Returns:
the padded string

countChars

public static int countChars(java.lang.String str,
                             char c)
Count the number of occurrences of a character in a string

Parameters:
str - the string
c - the character
Returns:
the number of occurrences

countLines

public static int countLines(java.lang.String text)
Count the number of lines in a string

Parameters:
text - The test
Returns:
the count

sleep

public static void sleep(long millis)
Sleep for a period

Parameters:
millis - the period to sleep in milliseconds