com.ls.util
Class Tool

java.lang.Object
  |
  +--com.ls.util.Tool

public class Tool
extends Object

Define methods related with date and number convertions used in credit cards.

Version:
$Revision: 1.5 $
Author:
Last modified by $Author: TBerk $

Field Summary
protected static DecimalFormat dc
          Variable for decimal format definition
protected static char decimalSeparator
          Decimal seperator of decimal numbers
protected static char groupingSeparator
          Grouping seperator of decimal numbers
protected static String stcDefaultBdFormat
          default format field format for big decimals
protected static int stcRoundingMode
          Round mode
protected static int stcScale
          Scale
 
Constructor Summary
Tool()
          Constructor.
 
Method Summary
static String bigDecimalToString(BigDecimal bd)
          Returns a date object from the given day, month and year value
static boolean dateValidation(String day, String month, String year)
          Checks a date from the given day, month and year values.
static String formatBigDecimalString(String bdString)
          Returns a date object from the given day, month and year value
static BigDecimal getBigDecimal(String bdString)
          Returns a date object from the given day, month and year value
static Date getDate(String day, String month, String year)
          Returns a date object from the given day, month and year value.
static double getDouble(String str)
          converts a String number to a double value
static int getInt(String str)
          converts a String number to a int value
static long getLong(String str)
          converts a String number to a long value
static String getRandomDigits(int numberOfDigits)
          Get a string with N random digits.
static String getRandomDigits(int numberOfDigits, int seed)
          Get a string with N random digits.
static String getRandomLetters(int numberOfLetters, int seed)
          Get N random uppercase letters.
static String getRandomMixedLetters(int numberOfLetters, int seed)
          Get N random mixed uppercase and lowercase letters.
static int getRoundingMode()
          Returns the roundingMode used for bigDecimal
static int getScale()
          Returns the scale used for bigDecimal
static Date monthYearToDate(String monthYear)
          Returns the date object from the given month and year values. (for the credit card)
static Integer parseInt(String str)
          converts a String number to a Integer value
static void setBigDecimalFormatPattern(String pattern)
          Sets the pattern used to format a string
static void setDecimalFormat()
          Sets the decimal format to it's standard value
static void setRoundingMode(int roundingMode)
          Sets the roundingMode used for bigDecimal
static void setScale(int scale)
          Sets the scale used for bigDecimal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stcScale

protected static int stcScale
Scale

stcRoundingMode

protected static int stcRoundingMode
Round mode

stcDefaultBdFormat

protected static String stcDefaultBdFormat
default format field format for big decimals

dc

protected static DecimalFormat dc
Variable for decimal format definition

decimalSeparator

protected static char decimalSeparator
Decimal seperator of decimal numbers

groupingSeparator

protected static char groupingSeparator
Grouping seperator of decimal numbers
Constructor Detail

Tool

public Tool()
Constructor. Empty.
Method Detail

dateValidation

public static boolean dateValidation(String day,
                                     String month,
                                     String year)
Checks a date from the given day, month and year values.
Parameters:
day - Day of month (eg. '5', '06', '23', etc).
month - Month of year (eg. '1', '03', etc).
year - Year part of the date (eg. '1972', '2003', etc)
Returns:
true if date is OK

monthYearToDate

public static Date monthYearToDate(String monthYear)
Returns the date object from the given month and year values. (for the credit card)
Parameters:
monthYear - Month of year
Returns:
date the last day of month associated with mm/yy if everything not o.k. returns a null

getDate

public static Date getDate(String day,
                           String month,
                           String year)
Returns a date object from the given day, month and year value.
Parameters:
day - Day of month (1-31)
month - Month of year (1-12)
year - Year (1971-2xxx)
Returns:
Date build from the given day, month and year value

getInt

public static int getInt(String str)
converts a String number to a int value
Parameters:
str - String with a number in it
Returns:
int value of the number

parseInt

public static Integer parseInt(String str)
converts a String number to a Integer value
Parameters:
str - String with a number in it
Returns:
int value of the number (default is null)

getLong

public static long getLong(String str)
converts a String number to a long value
Parameters:
str - String with a number in it
Returns:
long value of the string

getDouble

public static double getDouble(String str)
converts a String number to a double value
Parameters:
str - String with a number in it
Returns:
double value of the string

getRandomLetters

public static String getRandomLetters(int numberOfLetters,
                                      int seed)
Get N random uppercase letters.
Parameters:
numberOfLetters - the number of letters to produce
seed - additional seed initializer
Returns:
String with N letters.

getRandomMixedLetters

public static String getRandomMixedLetters(int numberOfLetters,
                                           int seed)
Get N random mixed uppercase and lowercase letters.
Parameters:
numberOfLetters - the number of letters to produce
seed - additional seed initializer
Returns:
String with N letters.

getRandomDigits

public static String getRandomDigits(int numberOfDigits)
Get a string with N random digits.
Parameters:
numberOfDigits - the number of digits to produce
Returns:
String with a random number being four digits long

getRandomDigits

public static String getRandomDigits(int numberOfDigits,
                                     int seed)
Get a string with N random digits.
Parameters:
numberOfDigits - the number of digits to produce
seed - the number to seed the random generator with
Returns:
String with a random number being four digits long

getBigDecimal

public static BigDecimal getBigDecimal(String bdString)
Returns a date object from the given day, month and year value
Parameters:
bdString - string representation of BigDecimal.
Returns:
The BigDecimal represented by the String or Null if the String was not parsable

setDecimalFormat

public static void setDecimalFormat()
Sets the decimal format to it's standard value

bigDecimalToString

public static String bigDecimalToString(BigDecimal bd)
Returns a date object from the given day, month and year value
Parameters:
bd - The BigDecimal that has to be converted
Returns:
A pretty Print of the given BigDecimal in a String

formatBigDecimalString

public static String formatBigDecimalString(String bdString)
Returns a date object from the given day, month and year value
Parameters:
bdString - String representation of BigDecimal.
Returns:
A pretty Print of the given decimal in a String

setBigDecimalFormatPattern

public static void setBigDecimalFormatPattern(String pattern)
Sets the pattern used to format a string
Parameters:
pattern - Pattern representing the format for the pretty print

setScale

public static void setScale(int scale)
Sets the scale used for bigDecimal
Parameters:
scale - Scale used for bigDecimal

setRoundingMode

public static void setRoundingMode(int roundingMode)
Sets the roundingMode used for bigDecimal
Parameters:
roundingMode - used for bigDecimal

getScale

public static int getScale()
Returns the scale used for bigDecimal
Returns:
Scale used for bigDecimal

getRoundingMode

public static int getRoundingMode()
Returns the roundingMode used for bigDecimal
Returns:
RoundingMode used for bigDecimal