2016/02/07 - Apache Onami has been retired.

For more information, please explore the Attic.

Apache Onami Converters - i18n

The i18n module contains useful i18n converters implementations.

Users that want to use the Format module, have to add the following dependency in the pom.xml:

<dependency>
  <groupId>org.apache.onami.converters</groupId>
  <artifactId>org.apache.onami.converters.i18n</artifactId>
  <version>1.0.1-SNAPSHOT</version>
  <scope>compile</scope>
</dependency>

The Converters

CurrencyConverter

Is the converter that converts a java.lang.String representation to a java.util.Currency.

DateConverter

Is the converter that converts a java.lang.String representation to a java.util.Calendar and to java.util.Date.

By default, this converter manages the following ISO Date format representation:

  • yyyy;
  • yyyy-MM;
  • yyyy-MM-dd;
  • yyyy-MM-dd'T'hh:mmZ;
  • yyyy-MM-dd'T'hh:mm:ssZ;
  • yyyy-MM-dd'T'hh:mm:ss.sZ

    If users need to add new supported date formats, first they have to retrieve the DateConverter, then add a new pattern:

    DateConverter dateConverter = module.lookup( Date.class, DateConverter.class );
    dateConverter.addPattern( "EEE, MMM d, ''yy" );

    If users need to set the java.util.Locale and/or the java.util.TimeZone, first they have to retrieve the DateConverter, then set their preferences:

    import java.util.Locale;
    import java.util.TimeZone;
    ...
    DateConverter dateConverter = module.lookup( Date.class, DateConverter.class );
    dateConverter.setLocale( Locale.getDefault() );
    dateConverter.setTimeZone( TimeZone.getDefault() );

LocaleConverter

Is the converter that converts a java.lang.String representation to a java.util.Locale

The converter checks first if the input String matches with the pattern languageCode_counrtyCode to create the java.util.Locale otherwise will use the input value as Locale language.

TimeZoneConverter

Is the converter that converts a java.lang.String representation to a java.util.TimeZone.