com.prowidesoftware.swift.utils
Class SwiftFormatUtils

java.lang.Object
  extended by com.prowidesoftware.swift.utils.SwiftFormatUtils

public class SwiftFormatUtils
extends java.lang.Object

This class provides methods to convert field components to objects. It handles for example; dates, currencies and general functions defined in the SWIFT standard.

Since:
6.0
Version:
$Id: SwiftFormatUtils.java,v 1.3 2013/05/16 16:02:20 mgriffa Exp $
Author:
www.prowidesoftware.com

Constructor Summary
SwiftFormatUtils()
           
 
Method Summary
static java.lang.String getBIC(BIC bic)
          Gets the code from the parameter BIC.
static BIC getBIC(java.lang.String code)
           
static java.lang.String getCurrency(java.util.Currency currency)
          Gets the currency code from the parameter Currency.
static java.util.Currency getCurrency(java.lang.String code)
           
static java.lang.String getDate1(java.util.Calendar date)
          Parses a Calendar object into a DATE1 string.
static java.util.Calendar getDate1(java.lang.String strDate)
          Parses a DATE1 string (accept dates in format MMDD) into a Calendar object.
static java.lang.String getDate2(java.util.Calendar date)
          Parses a Calendar object into a DATE2 string.
static java.util.Calendar getDate2(java.lang.String strDate)
          Parses a DATE2 string (accept dates in format YYMMDD) into a Calendar object.
static java.lang.String getDate3(java.util.Calendar date)
          Parses a Calendar object into a DATE1 string.
static java.util.Calendar getDate3(java.lang.String strDate)
          Parses a DATE3 string (accept dates in format YYMM) into a Calendar object.
static java.lang.String getDate4(java.util.Calendar date)
          Parses a Calendar object into a DATE1 string.
static java.util.Calendar getDate4(java.lang.String strDate)
          Parses a DATE4 string (accept dates in format YYYYMMDD) into a Calendar object.
static java.util.Calendar getHhmm(java.lang.String hhmm)
           
static java.lang.String getNumber(java.lang.Number number)
          Parses a Number into a SWIFT string number ####,## where trunked zero decimals and mandatory decimal separator.
static java.lang.Number getNumber(java.lang.String amount)
          Parses a value into a java Number (BigDecimal) using the comma for decimal separator.
static java.lang.String getOffset(java.util.Calendar date)
          Parses a Calendar object into a offset string.
static java.util.Calendar getOffset(java.lang.String string)
           
static java.lang.Character getSign(java.lang.String string)
           
static java.lang.String getTime2(java.util.Calendar date)
          Parses a Calendar object into a TIME2 string.
static java.util.Calendar getTime2(java.lang.String hhmmss)
           
static java.lang.String getTime3(java.util.Calendar date)
          Parses a Calendar object into a TIME3 string.
static java.util.Calendar getTime3(java.lang.String hhmmss)
           
static java.lang.String getYear(java.util.Calendar date)
          Parses a Calendar object into a YYYY string.
static java.util.Calendar getYear(java.lang.String strDate)
          Parses a YEAR string (accept dates in format YYYY) into a Calendar object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SwiftFormatUtils

public SwiftFormatUtils()
Method Detail

getDate2

public static java.util.Calendar getDate2(java.lang.String strDate)
Parses a DATE2 string (accept dates in format YYMMDD) into a Calendar object.

Parameters:
strDate - string to parse
Returns:
parsed date or null if the argument did not matched the expected date format

getDate2

public static java.lang.String getDate2(java.util.Calendar date)
Parses a Calendar object into a DATE2 string.

Parameters:
date - Calendar to parse
Returns:
parsed date or null if the calendar is null

getDate1

public static java.util.Calendar getDate1(java.lang.String strDate)
Parses a DATE1 string (accept dates in format MMDD) into a Calendar object.

Parameters:
strDate - string to parse
Returns:
parsed date or null if the argument did not matched the expected date format

getDate1

public static java.lang.String getDate1(java.util.Calendar date)
Parses a Calendar object into a DATE1 string.

Parameters:
date - Calendar to parse
Returns:
parsed date or null if the calendar is null
Since:
6.4

getDate3

public static java.util.Calendar getDate3(java.lang.String strDate)
Parses a DATE3 string (accept dates in format YYMM) into a Calendar object.

Parameters:
strDate - string to parse
Returns:
parsed date or null if the argument did not matched the expected date format

getDate3

public static java.lang.String getDate3(java.util.Calendar date)
Parses a Calendar object into a DATE1 string.

Parameters:
date - Calendar to parse
Returns:
parsed date or null if the calendar is null
Since:
6.4

getDate4

public static java.util.Calendar getDate4(java.lang.String strDate)
Parses a DATE4 string (accept dates in format YYYYMMDD) into a Calendar object.

Parameters:
strDate - string to parse
Returns:
parsed date or null if the argument did not matched the expected date format

getDate4

public static java.lang.String getDate4(java.util.Calendar date)
Parses a Calendar object into a DATE1 string.

Parameters:
date - Calendar to parse
Returns:
parsed date or null if the calendar is null
Since:
6.4

getYear

public static java.util.Calendar getYear(java.lang.String strDate)
Parses a YEAR string (accept dates in format YYYY) into a Calendar object.

Parameters:
strDate - string to parse
Returns:
parsed date or null if the argument did not matched the expected date format

getYear

public static java.lang.String getYear(java.util.Calendar date)
Parses a Calendar object into a YYYY string.

Parameters:
date - Calendar to parse
Returns:
parsed date or null if the calendar is null
Since:
6.4

getNumber

public static java.lang.Number getNumber(java.lang.String amount)
Parses a value into a java Number (BigDecimal) using the comma for decimal separator.

Parameters:
amount - to parse
Returns:
Number of the parsed amount or null if the number could not be parsed

getNumber

public static java.lang.String getNumber(java.lang.Number number)
Parses a Number into a SWIFT string number ####,## where trunked zero decimals and mandatory decimal separator.

Parameters:
number - to parse
Returns:
Number of the parsed amount or null if the number is null

getHhmm

public static java.util.Calendar getHhmm(java.lang.String hhmm)
Parameters:
hhmm - hour and minutes
Returns:
a Calendar set with the given hour and minutes

getTime2

public static java.util.Calendar getTime2(java.lang.String hhmmss)
Parameters:
hhmmss - hour, minutes and seconds
Returns:
a Calendar set with the given hour, minutes and seconds

getTime2

public static java.lang.String getTime2(java.util.Calendar date)
Parses a Calendar object into a TIME2 string.

Parameters:
date - Calendar to parse
Returns:
parsed time or null if the calendar is null
Since:
6.4

getTime3

public static java.util.Calendar getTime3(java.lang.String hhmmss)
Parameters:
hhmmss - hour, minutes and seconds
Returns:
a Calendar set with the given hour, or and hour and minutes

getTime3

public static java.lang.String getTime3(java.util.Calendar date)
Parses a Calendar object into a TIME3 string.

Parameters:
date - Calendar to parse
Returns:
parsed time or null if the calendar is null
Since:
6.4

getSign

public static java.lang.Character getSign(java.lang.String string)
Parameters:
string - with a single character
Returns:
the Character for the given string

getOffset

public static java.util.Calendar getOffset(java.lang.String string)
Parameters:
string - with an offset
Returns:
a Calendar set with hour and minutes from the offset

getOffset

public static java.lang.String getOffset(java.util.Calendar date)
Parses a Calendar object into a offset string.

Parameters:
date - Calendar to parse
Returns:
parsed time or null if the calendar is null
Since:
6.4

getCurrency

public static java.util.Currency getCurrency(java.lang.String code)
Parameters:
code - string with a currency code
Returns:
a Currency initialized from the parameter code

getCurrency

public static java.lang.String getCurrency(java.util.Currency currency)
Gets the currency code from the parameter Currency.

Parameters:
currency - Currency to use
Returns:
the string with the currency code
Since:
6.4

getBIC

public static BIC getBIC(java.lang.String code)
Parameters:
code - string with a BIC code
Returns:
a BIC initialized from the parameter code

getBIC

public static java.lang.String getBIC(BIC bic)
Gets the code from the parameter BIC.

Parameters:
bic - BIC to use
Returns:
the string with the BIC code
Since:
6.4