/** * @return all registered Datatype ids. */ public static Set<String> getIds() { return getDatatypeRegistry().getIds(); }
/** * Format Date (date without time) using {@code dateFormat} string specified in the main message pack. * @return string representation or empty string if the value is null */ public String formatDate(@Nullable Date value) { return datatypeRegistry.getNN(java.sql.Date.class).format(value, uss.getLocale()); }
protected Datatype getDatatype(Class clazz) { if (clazz == Integer.TYPE || clazz == Byte.TYPE || clazz == Short.TYPE) return Datatypes.get(Integer.class); if (clazz == Long.TYPE) return Datatypes.get(Long.class); if (clazz == Boolean.TYPE) return Datatypes.get(Boolean.class); return Datatypes.get(clazz); }
@Override public String format(Object value, Locale locale) { if (value == null) { return ""; } FormatStrings formatStrings = AppBeans.get(FormatStringsRegistry.class).getFormatStrings(locale); if (formatStrings == null) { return format(value); } return (boolean) value ? formatStrings.getTrueString() : formatStrings.getFalseString(); }
/** * Get Datatype instance by the corresponding Java class. This method tries to find matching supertype too. * @return Datatype instance or null if not found */ @Nullable public static <T> Datatype<T> get(Class<T> clazz) { return getDatatypeRegistry().get(clazz); }
/** * Returns localized format strings. * @param locale selected locale * @return {@link FormatStrings} object, or null if no formats are registered for the locale */ @Nullable public static FormatStrings getFormatStrings(Locale locale) { return getFormatStringsRegistry().getFormatStrings(locale); }
/** * Get Datatype instance by the corresponding Java class. This method tries to find matching supertype too. * @return Datatype instance * @throws IllegalArgumentException if no datatype suitable for the given type found */ @Nonnull public static <T> Datatype<T> getNN(Class<T> clazz) { return getDatatypeRegistry().getNN(clazz); }
/** * Returns localized format strings. * @param locale selected locale * @return {@link FormatStrings} object. Throws exception if not found. */ @Nonnull public static FormatStrings getFormatStringsNN(Locale locale) { return getFormatStringsRegistry().getFormatStringsNN(locale); }
/** * Parse Date (time without date) using {@code timeFormat} string specified in the main message pack. * @return Date value or null if a blank string is provided */ @Nullable public Date parseTime(String str) throws ParseException { return datatypeRegistry.getNN(Time.class).parse(str, uss.getLocale()); }
/** * Format BigDecimal using {@code decimalFormat} string specified in the main message pack. * @return string representation or empty string if the value is null */ public String formatBigDecimal(@Nullable BigDecimal value) { return datatypeRegistry.getNN(BigDecimal.class).format(value, uss.getLocale()); }
protected Datatype getDatatype(Class clazz) { if (clazz == Integer.TYPE || clazz == Byte.TYPE || clazz == Short.TYPE) return Datatypes.get(Integer.class); if (clazz == Long.TYPE) return Datatypes.get(Long.class); if (clazz == Boolean.TYPE) return Datatypes.get(Boolean.class); return Datatypes.get(clazz); }
/** * Get Datatype instance by its unique name * @return Datatype instance * @throws IllegalArgumentException if no datatype with the given name found */ @Nonnull public static Datatype get(String name) { return getDatatypeRegistry().get(name); }
/** * Parse BigDecimal using {@code decimalFormat} string specified in the main message pack. * @return BigDecimal value or null if a blank string is provided */ @Nullable public BigDecimal parseBigDecimal(String str) throws ParseException { return datatypeRegistry.getNN(BigDecimal.class).parse(str, uss.getLocale()); }
/** * Format Boolean using {@code trueString} and {@code falseString} strings specified in the main message pack. * @return string representation or empty string if the value is null */ public String formatBoolean(@Nullable Boolean value) { return datatypeRegistry.getNN(Boolean.class).format(value, uss.getLocale()); }
public DateSerializer() { dateDatatype = Datatypes.get(Date.class); }
/** * Parse Integer using {@code integerFormat} string specified in the main message pack. * @return Integer value or null if a blank string is provided */ @Nullable public Integer parseInteger(String str) throws ParseException { return datatypeRegistry.getNN(Integer.class).parse(str, uss.getLocale()); }