Package org.cyclos.impl.utils.formatting
Class FormatterImpl
- java.lang.Object
-
- org.cyclos.model.utils.AbstractFormatter
-
- org.cyclos.impl.utils.formatting.FormatterImpl
-
- All Implemented Interfaces:
Formatter
- Direct Known Subclasses:
SmsOperationFormatterImpl
public class FormatterImpl extends AbstractFormatter
Used to format different data types
-
-
Field Summary
-
Fields inherited from interface org.cyclos.utils.Formatter
VARIABLE_SCALE
-
-
Constructor Summary
Constructors Constructor Description FormatterImpl(ConfigurationAccessor configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringformat(Object object)Tests the object type, invoking one of the specific format methodsStringformat(BigDecimal number, int scale)Formats a number with the given scaleStringformat(Date date)Stringformat(Token token)Stringformat(Account account)Stringformat(AccountLocator locator)Stringformat(Trans trans)Stringformat(CustomFieldValue<?,?,?,?> fieldValue)Stringformat(Address address)Stringformat(BasicUser user)Stringformat(Phone phone)Stringformat(Phone phone, boolean includeExtension)Stringformat(Record record)Stringformat(DatePeriod period)Stringformat(DecimalRange range)Stringformat(IntegerRange range)Stringformat(FormattedDate formattedDate)Stringformat(ShortFormat sf)Stringformat(INamedEntity namedEntity)Formats a named entityStringformat(ICustomFieldValue<?,?,?,?> customFieldValue)Formats a custom field valueStringformat(IDate date)Formats a date as date and timeStringformatAsDate(Date date)StringformatAsDate(IDate date)Formats an IDate as dateStringformatAsDiff(Date date)StringformatAsTime(Date date)StringformatAsTime(IDate date)Formats an IDate as timeStringformatId(IEntity entity)Formats the entity identifierStringformatShort(Date date)Includes the date part in the formatted result only if the difference between the date and the current date is less than 24 hours.CalendargetCalendar()It gets a calendar using the configuration's time zoneConfigurationAccessorgetConfiguration()ConversionHandlergetConversionHandler()CyclosPropertiesgetCyclosProperties()DataTranslationHandlergetDataTranslationHandler()StringgetDatePattern()Returns the date patternEntityManagerHandlergetEntityManagerHandler()StringgetTimePattern()Returns the time patternTranslationHandlergetTranslationHandler()protected Stringmessage(MessageFormat format, MessageKey key, Object... arguments)DateparseDate(String text)BigDecimalparseDecimal(String text, int scale)DateparseTime(String text)DateparseTimestamp(String text)-
Methods inherited from class org.cyclos.model.utils.AbstractFormatter
fixSignIfZero, format, format, format, format, format, format, format, format, format, format, format, format, format, format, format, format, format, format, format, format, format, format, format, format, format, formatAsDate, formatDuration, formatPercentage, formatPercentage, formatPercentage, formatPercentage, formatPercentage, formatPercentage, formatPeriod, formatRange, formatVariables, message, roundHour, splitDecimal
-
-
-
-
Constructor Detail
-
FormatterImpl
public FormatterImpl(ConfigurationAccessor configuration)
-
-
Method Detail
-
format
public String format(AccountLocator locator)
-
format
public String format(BigDecimal number, int scale)
Description copied from interface:FormatterFormats a number with the given scale
-
format
public String format(CustomFieldValue<?,?,?,?> fieldValue)
-
format
public String format(DatePeriod period)
-
format
public String format(DecimalRange range)
-
format
public String format(FormattedDate formattedDate)
-
format
public String format(ICustomFieldValue<?,?,?,?> customFieldValue)
Description copied from interface:FormatterFormats a custom field value- Specified by:
formatin interfaceFormatter- Overrides:
formatin classAbstractFormatter
-
format
public String format(IDate date)
Description copied from interface:FormatterFormats a date as date and time
-
format
public String format(INamedEntity namedEntity)
Description copied from interface:FormatterFormats a named entity- Specified by:
formatin interfaceFormatter- Overrides:
formatin classAbstractFormatter
-
format
public String format(IntegerRange range)
-
format
public String format(Object object)
Description copied from interface:FormatterTests the object type, invoking one of the specific format methods- Specified by:
formatin interfaceFormatter- Overrides:
formatin classAbstractFormatter
-
format
public String format(ShortFormat sf)
-
formatAsDate
public String formatAsDate(IDate date)
Description copied from interface:FormatterFormats an IDate as date
-
formatAsTime
public String formatAsTime(IDate date)
Description copied from interface:FormatterFormats an IDate as time
-
formatId
public String formatId(IEntity entity)
Description copied from interface:FormatterFormats the entity identifier
-
formatShort
public String formatShort(Date date)
Includes the date part in the formatted result only if the difference between the date and the current date is less than 24 hours.
-
getCalendar
public Calendar getCalendar()
It gets a calendar using the configuration's time zone
-
getConfiguration
public ConfigurationAccessor getConfiguration()
-
getConversionHandler
public ConversionHandler getConversionHandler()
-
getCyclosProperties
public CyclosProperties getCyclosProperties()
-
getDataTranslationHandler
public DataTranslationHandler getDataTranslationHandler()
-
getDatePattern
public String getDatePattern()
Description copied from interface:FormatterReturns the date pattern
-
getEntityManagerHandler
public EntityManagerHandler getEntityManagerHandler()
-
getTimePattern
public String getTimePattern()
Description copied from interface:FormatterReturns the time pattern
-
getTranslationHandler
public TranslationHandler getTranslationHandler()
-
parseDate
public Date parseDate(String text) throws CoercionException
- Throws:
CoercionException
-
parseDecimal
public BigDecimal parseDecimal(String text, int scale)
-
message
protected String message(MessageFormat format, MessageKey key, Object... arguments)
- Specified by:
messagein classAbstractFormatter
-
-