use of com.webobjects.foundation.NSNumberFormatter in project wonder-slim by undur.
the class AjaxSlider method takeValuesFromRequest.
@Override
public void takeValuesFromRequest(WORequest worequest, WOContext wocontext) {
String format = null;
try {
format = (String) valueForBinding("numberformat", "0");
Number num = worequest.numericFormValueForKey(wocontext.elementID(), new NSNumberFormatter(format));
if (num != null) {
setValueForBinding(num, "value");
}
} catch (NumberFormatException ex) {
log.error("Could not format value with pattern '{}'.", format, ex);
}
super.takeValuesFromRequest(worequest, wocontext);
}
use of com.webobjects.foundation.NSNumberFormatter in project wonder-slim by undur.
the class ERXNumberFormatter method numberFormatterForPattern.
/**
* Returns a shared instance for the specified pattern.
* @return shared instance of formatter
*/
public static NSNumberFormatter numberFormatterForPattern(String pattern) {
NSNumberFormatter formatter;
if (ERXLocalizer.useLocalizedFormatters()) {
ERXLocalizer localizer = ERXLocalizer.currentLocalizer();
formatter = (NSNumberFormatter) localizer.localizedNumberFormatForKey(pattern);
} else {
formatter = _repository.get(pattern);
if (formatter == null) {
formatter = new ERXNumberFormatter(pattern);
_repository.put(pattern, formatter);
}
}
return formatter;
}
use of com.webobjects.foundation.NSNumberFormatter in project wonder-slim by undur.
the class ERXLocalizer method localizedNumberFormatForKey.
/**
* Returns a localized number formatter for the given key. Also, can localize units to, just define in your
* Localizable.strings a suitable key, with the appropriate pattern.
*
* @return the formatter object
*/
public Format localizedNumberFormatForKey(String formatString) {
formatString = formatString == null ? "#,##0.00;-(#,##0.00)" : formatString;
formatString = localizedStringForKeyWithDefault(formatString);
Format result = _numberFormatters.get(formatString);
if (result == null) {
Locale current = locale();
NSNumberFormatter formatter = new ERXNumberFormatter();
formatter.setLocale(current);
formatter.setLocalizesPattern(true);
formatter.setPattern(formatString);
result = formatter;
_numberFormatters.put(formatString, result);
}
return result;
}
Aggregations