nl.openedge.baritus.converters
Class DateLocaleConverter

java.lang.Object
  extended bynl.openedge.baritus.converters.BaseLocaleConverter
      extended bynl.openedge.baritus.converters.DateLocaleConverter
All Implemented Interfaces:
Converter, Formatter, LocaleConverter

public class DateLocaleConverter
extends BaseLocaleConverter

Standard LocaleConverter implementation that converts an incoming locale-sensitive String into a java.util.Date object, optionally using a default value or throwing a ConversionException if a conversion error occurs.

Author:
Yauheny Mikulski, Michael Szlapa

Field Summary
 
Fields inherited from class nl.openedge.baritus.converters.BaseLocaleConverter
locale, locPattern, pattern
 
Constructor Summary
DateLocaleConverter()
          Create a LocaleConverter that will throw a ConversionException if a conversion error occurs.
DateLocaleConverter(java.util.Locale locale)
          Create a LocaleConverter that will throw a ConversionException if a conversion error occurs.
DateLocaleConverter(java.util.Locale locale, java.lang.String pattern)
          Create a LocaleConverter that will throw a ConversionException if a conversion error occurs.
 
Method Summary
 java.lang.Object convert(java.lang.Class type, java.lang.Object value, java.lang.String pattern)
          Convert the specified locale-sensitive input object into an output object of the specified type.
 java.lang.String format(java.lang.Object value, java.lang.String pattern)
          format value with pattern or using the default pattern
 int getDateStyle()
          get date style
 boolean isLenient()
          Returns whether date formatting is lenient.
protected  java.lang.Object parse(java.lang.Object value, java.lang.String pattern)
          Convert the specified locale-sensitive input object into an output object of the specified type.
 void setDateStyle(int dateStyle)
          set date style
 void setLenient(boolean lenient)
          Specify whether or not date-time parsing should be lenient.
 
Methods inherited from class nl.openedge.baritus.converters.BaseLocaleConverter
convert, convert, convert, getLocale, getPattern, setLocale, setPattern
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateLocaleConverter

public DateLocaleConverter()
Create a LocaleConverter that will throw a ConversionException if a conversion error occurs. The locale is the default locale for this instance of the Java Virtual Machine and an unlocalized pattern is used for the convertion.


DateLocaleConverter

public DateLocaleConverter(java.util.Locale locale)
Create a LocaleConverter that will throw a ConversionException if a conversion error occurs. An unlocalized pattern is used for the convertion.

Parameters:
locale - The locale

DateLocaleConverter

public DateLocaleConverter(java.util.Locale locale,
                           java.lang.String pattern)
Create a LocaleConverter that will throw a ConversionException if a conversion error occurs. An unlocalized pattern is used for the convertion.

Parameters:
locale - The locale
pattern - The convertion pattern
Method Detail

isLenient

public boolean isLenient()
Returns whether date formatting is lenient.

Returns:
true if the DateFormat used for formatting is lenient
See Also:
DateFormat.isLenient()

setLenient

public void setLenient(boolean lenient)
Specify whether or not date-time parsing should be lenient.

Parameters:
lenient - true if the DateFormat used for formatting should be lenient
See Also:
DateFormat.setLenient(boolean)

getDateStyle

public int getDateStyle()
get date style

Returns:
int date style as a constant from DateFormat

setDateStyle

public void setDateStyle(int dateStyle)
set date style

Parameters:
dateStyle -

parse

protected java.lang.Object parse(java.lang.Object value,
                                 java.lang.String pattern)
                          throws ConversionException
Convert the specified locale-sensitive input object into an output object of the specified type.

Specified by:
parse in class BaseLocaleConverter
Parameters:
value - The input object to be converted
pattern - The pattern is used for the convertion
Throws:
ConversionException - if conversion cannot be performed successfully

format

public java.lang.String format(java.lang.Object value,
                               java.lang.String pattern)
                        throws java.lang.IllegalArgumentException
format value with pattern or using the default pattern

Parameters:
value - The input object to be formatted
pattern - The pattern is used for the conversion
Throws:
java.lang.IllegalArgumentException - if formatting cannot be performed successfully
See Also:
Formatter.format(java.lang.Object, java.lang.String)

convert

public java.lang.Object convert(java.lang.Class type,
                                java.lang.Object value,
                                java.lang.String pattern)
Convert the specified locale-sensitive input object into an output object of the specified type.

Parameters:
type - Data type to which this value should be converted
value - The input object to be converted
pattern - The pattern is used for the convertion
Throws:
ConversionException - if conversion cannot be performed successfully


Copyright © 2003-2004 Open Edge. All Rights Reserved.