Großmarkt

market
Class Conversions

java.lang.Object
  |
  +--market.Conversions

public abstract class Conversions
extends Object

A collection of methods to convert Strings, numbers and other Objects into another format.


Constructor Summary
Conversions()
           
 
Method Summary
static String convertComma(String s)
          Converts all commas in a string into points (e.g. 1,225 => 1.225).
static Calendar createToday()
           
static int currencyToInt(String s, boolean euroToCents)
          Converts a currency string into an int.
static CatalogItemImpl customerToCI(UCustomer customer)
          Creates a CatalogItemImpl from a UCustomer.
static int dayDifference(Calendar cEarly, Calendar cLate)
          Computes the difference between two dates in days.
static String doubleToCurrency(double d)
          Converts a double that represents an amount of money in cents into a String.
static String doubleToCurrency(double d, String extra)
          Converts a double that represents an amount of money in cents into a String, that represents the money in Euros (or Dollars...).
static String fixedDecimal(double d, int decimalPlace)
          Converts a double into a String with a fixed number of decimal places.
static CIArticle recordToCIArticle(Object record)
          Casts a CIArticle, a CountingStockTableModel.Record or a StockItemImpl into a CIArticle if possible.
static double round(double d, int decimalPlace)
          Cuts a double after the specified number of decimal places.
static Calendar stringToCalendar(String dateString)
          Converts a date string ("dd.MM.yyyy") to a Calendar date.
static String valueToCurrency(Value v)
          Converts a Value that represents an amount of money in cents into a String, that represents the money in Euros (or Dollars...).
static String valueToCurrency(Value v, String extra)
          Converts a Value that represents an amount of money in cents into a String, that represents the money in Euros (or Dollars...).
static Double valueToDouble(Value v)
          Converts a Value to a Double.
static int valueToInt(Value v)
          Converts a Value to an int.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Conversions

public Conversions()
Method Detail

fixedDecimal

public static String fixedDecimal(double d,
                                  int decimalPlace)
Converts a double into a String with a fixed number of decimal places.

Parameters:
d - the double to be converted.
decimalPlace - the number of decimal places
Returns:
the formatted String.

valueToCurrency

public static String valueToCurrency(Value v)
Converts a Value that represents an amount of money in cents into a String, that represents the money in Euros (or Dollars...).

Parameters:
v - the value to be converted.
Returns:
the formatted String.

valueToCurrency

public static String valueToCurrency(Value v,
                                     String extra)
Converts a Value that represents an amount of money in cents into a String, that represents the money in Euros (or Dollars...).

Parameters:
v - the value to be converted.
extra - an extra String added behind the converted value.
Returns:
the formatted String.

doubleToCurrency

public static String doubleToCurrency(double d)
Converts a double that represents an amount of money in cents into a String. that represents the money in Euros (or Dollars...).

Parameters:
d - the double to be converted.
Returns:
the formatted String.

doubleToCurrency

public static String doubleToCurrency(double d,
                                      String extra)
Converts a double that represents an amount of money in cents into a String, that represents the money in Euros (or Dollars...).

Parameters:
d - the double to be converted.
extra - an extra String added behind the converted double.
Returns:
the formatted String.

valueToDouble

public static Double valueToDouble(Value v)
Converts a Value to a Double.

Parameters:
v - the Value to be converted.
Returns:
the converted Value as Double.

currencyToInt

public static int currencyToInt(String s,
                                boolean euroToCents)
Converts a currency string into an int.

Parameters:
s - the string to be converted.
euroToCents - if true, the string is interpreted as Euro value and multiplied by 100, otherwise the string is assumed to represent cents already.
Returns:
the money as cents.

round

public static double round(double d,
                           int decimalPlace)
Cuts a double after the specified number of decimal places.

Parameters:
d - the double to be rounded.
decimalPlace - the decimal place after which is cut.
Returns:
the rounded double.

convertComma

public static String convertComma(String s)
Converts all commas in a string into points (e.g. 1,225 => 1.225).

Parameters:
s - the String to be converted.
Returns:
the converted String.

recordToCIArticle

public static CIArticle recordToCIArticle(Object record)
Casts a CIArticle, a CountingStockTableModel.Record or a StockItemImpl into a CIArticle if possible. If the object cannot be converted null is returned.

Parameters:
record - the Object to be cast.
Returns:
the cast object.

customerToCI

public static CatalogItemImpl customerToCI(UCustomer customer)
Creates a CatalogItemImpl from a UCustomer.

Parameters:
customer - the customer to create the CatalogItemImpl from.
Returns:
the created CatalogItemImpl.

stringToCalendar

public static Calendar stringToCalendar(String dateString)
Converts a date string ("dd.MM.yyyy") to a Calendar date.

Parameters:
dateString - the String representing the date.
Returns:
the Calendar.

createToday

public static Calendar createToday()
Returns:
today's (today means "realtime today") date with time set to 0:00.00.

valueToInt

public static int valueToInt(Value v)
Converts a Value to an int.

Parameters:
v - the Value to be converted.
Returns:
the converted Value as int.

dayDifference

public static int dayDifference(Calendar cEarly,
                                Calendar cLate)
Computes the difference between two dates in days.

Parameters:
cEarly - the first date.
cLate - the second date.
Returns:
the difference in days.

Großmarkt