IMC Epclient 5.0.3

at.spardat.enterprise.fmt
Class ATimeStampFmt

java.lang.Object
  extended byat.spardat.enterprise.fmt.IFmt
      extended byat.spardat.enterprise.fmt.ATimeStampFmt
All Implemented Interfaces:
java.lang.Cloneable

public class ATimeStampFmt
extends IFmt

Converts between internal and external format of ATimeStamps. The implementation of java.text.DateFormat is used internally.

The internal string format is a decimally encoded number, followed by a blank, followed by a decimally encoded number. The first number is the number of seconds since 19700101 (like a java.util.Date, without millisecond part). The second number denotes the number of nanoseconds. For example, the internal encoding of the timestamp '2003-02-28 09:53:39.955' is '1046422419 955000000'.

A warning: Do not let the user input timestamps. Although this formatter handles it, it is almost impossible for the user to provide a long, locale dependent input pattern he does not know in advance.


Field Summary
static int FULL
           
static int LONG
           
static int MEDIUM
           
static int SHORT
           
 
Fields inherited from class at.spardat.enterprise.fmt.IFmt
DEFAULT, LAST_STYLE, MANDATORY, style_
 
Constructor Summary
ATimeStampFmt(int styleDate, int styleTime, java.util.Locale l)
          Constructor for ATimeStampFmt.
ATimeStampFmt(java.lang.String pattern, java.util.Locale l, int style)
          Constructs a ATimeStampFmt using a java.text.SimpleDateFormat pattern.
 
Method Summary
 java.lang.Object clone()
          Returns a clone of this;
 java.lang.String format(java.lang.String internal)
          Transforms an internal encoding to an external.
static ATimeStampFmt getInstance(int styleDate, int styleTime, java.util.Locale l)
          Returns a localized formatter instance parametrized with styles
static ATimeStampFmt getInstance(java.lang.String pattern, int style, java.util.Locale l)
          Returns a non localized formatter where you have to provide the pattern yourself.
static ATimeStampFmt getInstance(java.lang.String pattern, java.util.Locale l)
          Returns a non localized formatter where you have to provide the pattern yourself.
 boolean isLegalExternalChar(char aChar)
          Examines whether a given character may be part of an external representation.
 boolean isLegalInternal(java.lang.String internal)
          Determines if the given string is a legal internal representation.
 boolean isOneWay()
          An IFmt is one way, if the external encoding may be generated out of the internal, but not vice versa.
 int maxLenOfExternal()
          Returns the maximum length an external string representation may have.
 boolean mayBeAppliedTo(byte type)
          Defines if this formatter is able to successfully format a specified type.
 java.lang.String parse(java.lang.String external)
          Tries to transform an external encoding to an internal.
 
Methods inherited from class at.spardat.enterprise.fmt.IFmt
checkMandatory, getStyle, isMandatory, setMandatory
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SHORT

public static final int SHORT
See Also:
"java.text.DateFormat.SHORT", Constant Field Values

MEDIUM

public static final int MEDIUM
See Also:
"java.text.DateFormat.MEDIUM", Constant Field Values

LONG

public static final int LONG
See Also:
"java.text.DateFormat.LONG", Constant Field Values

FULL

public static final int FULL
See Also:
"java.text.DateFormat.FULL", Constant Field Values
Constructor Detail

ATimeStampFmt

public ATimeStampFmt(int styleDate,
                     int styleTime,
                     java.util.Locale l)
Constructor for ATimeStampFmt.

Parameters:
styleDate - one of SHORT, MEDIUM, LONG, FULL or the IFmt-styles
styleTime - one of SHORT, MEDIUM, LONG, FULL or the IFmt-styles
l - the locale

ATimeStampFmt

public ATimeStampFmt(java.lang.String pattern,
                     java.util.Locale l,
                     int style)
Constructs a ATimeStampFmt using a java.text.SimpleDateFormat pattern.

Parameters:
pattern - a pattern as defined in java.text.SimpleDateFormat.
l - Locale
style - may be MANDATORY
Method Detail

getInstance

public static ATimeStampFmt getInstance(int styleDate,
                                        int styleTime,
                                        java.util.Locale l)
Returns a localized formatter instance parametrized with styles

Parameters:
styleDate - one of SHORT, MEDIUM, LONG, FULL or the IFmt-styles.
styleTime - one of SHORT, MEDIUM, LONG, FULL or the IFmt-styles.
l - the locale
Returns:
a instance of IFmt.

getInstance

public static ATimeStampFmt getInstance(java.lang.String pattern,
                                        java.util.Locale l)
Returns a non localized formatter where you have to provide the pattern yourself.

Parameters:
pattern - a pattern as defined in java.text.SimpleDateFormat.
l - Locale
Returns:
a instance of ATimeStampFmt.

getInstance

public static ATimeStampFmt getInstance(java.lang.String pattern,
                                        int style,
                                        java.util.Locale l)
Returns a non localized formatter where you have to provide the pattern yourself.

Parameters:
pattern - a pattern as defined in java.text.SimpleDateFormat.
style - may be MANDATORY
l - Locale
Returns:
a instance of ATimeStampFmt.

parse

public java.lang.String parse(java.lang.String external)
                       throws FmtParseException
Description copied from class: IFmt
Tries to transform an external encoding to an internal. Must not be called if isOneWay() yields true.

Specified by:
parse in class IFmt
Parameters:
external - the external encoding
Returns:
the internal encoding. May be the empty String, but never is null.
Throws:
FmtParseException
See Also:
IFmt.parse(String)

format

public java.lang.String format(java.lang.String internal)
Description copied from class: IFmt
Transforms an internal encoding to an external.

Specified by:
format in class IFmt
Parameters:
internal - the provided internal encoding. This String must satisfy the condition isLegalInternal(), otherwise the behaviour of this method is undefined.
Returns:
the external representation. May be the empty string, but is never null.
See Also:
IFmt.format(String)

maxLenOfExternal

public int maxLenOfExternal()
Description copied from class: IFmt
Returns the maximum length an external string representation may have.

Specified by:
maxLenOfExternal in class IFmt
Returns:
the maximum length or -1 if there is no known maximum.
See Also:
IFmt.maxLenOfExternal()

isLegalExternalChar

public boolean isLegalExternalChar(char aChar)
Description copied from class: IFmt
Examines whether a given character may be part of an external representation.

Specified by:
isLegalExternalChar in class IFmt
Parameters:
aChar - the character to check
Returns:
boolean if the character may be part of an external rep.
See Also:
IFmt.isLegalExternalChar(char)

isLegalInternal

public boolean isLegalInternal(java.lang.String internal)
Description copied from class: IFmt
Determines if the given string is a legal internal representation.

Specified by:
isLegalInternal in class IFmt
Parameters:
internal - the internal encoding.
Returns:
whether the provided string follows a legal internal encoding.
See Also:
IFmt.isLegalInternal(String)

isOneWay

public boolean isOneWay()
Description copied from class: IFmt
An IFmt is one way, if the external encoding may be generated out of the internal, but not vice versa.

Specified by:
isOneWay in class IFmt
Returns:
true, if format may be called, but parse not.
See Also:
IFmt.isOneWay()

mayBeAppliedTo

public boolean mayBeAppliedTo(byte type)
Description copied from class: IFmt
Defines if this formatter is able to successfully format a specified type.

Specified by:
mayBeAppliedTo in class IFmt
Parameters:
type - a type constant defined in Types.
See Also:
IFmt.mayBeAppliedTo(byte)

clone

public java.lang.Object clone()
Description copied from class: IFmt
Returns a clone of this;

Overrides:
clone in class IFmt
See Also:
IFmt.clone()

IMC Epclient 5.0.3