use of com.webobjects.foundation.NSTimestampFormatter in project wonder-slim by undur.
the class AjaxDatePicker method awake.
/**
* Sets up format / formatter values.
*/
@Override
public void awake() {
super.awake();
if (!(hasBinding("formatter") || hasBinding("format"))) {
// Default
format = "%m %d %Y";
formatter = new NSTimestampFormatter(format);
} else if (hasBinding("formatter")) {
formatter = (Format) valueForBinding("formatter");
if (formatter instanceof NSTimestampFormatter) {
format = ((NSTimestampFormatter) formatter).pattern();
} else if (formatter instanceof SimpleDateFormat) {
format = ((SimpleDateFormat) formatter).toPattern();
} else {
throw new RuntimeException("Can't handle formatter of class " + formatter.getClass().getCanonicalName());
}
} else {
format = (String) valueForBinding("format");
formatter = new NSTimestampFormatter(format);
}
format = translateSimpleDateFormatSymbols(format);
}
use of com.webobjects.foundation.NSTimestampFormatter in project wonder-slim by undur.
the class ERXTimestampFormatter method dateFormatterForPattern.
/**
* Returns a shared instance for the specified pattern.
*
* @return shared instance of formatter
*/
public static NSTimestampFormatter dateFormatterForPattern(String pattern) {
NSTimestampFormatter formatter;
if (ERXLocalizer.useLocalizedFormatters()) {
ERXLocalizer localizer = ERXLocalizer.currentLocalizer();
formatter = (NSTimestampFormatter) localizer.localizedDateFormatForKey(pattern);
} else {
synchronized (_repository) {
formatter = _repository.get(pattern);
if (formatter == null) {
formatter = new NSTimestampFormatter(pattern);
_repository.put(pattern, formatter);
}
}
}
return formatter;
}
use of com.webobjects.foundation.NSTimestampFormatter in project wonder-slim by undur.
the class ERXLocalizer method localizedDateFormatForKey.
/**
* Returns a localized date formatter for the given key.
*
* @return the formatter object
*/
public Format localizedDateFormatForKey(String formatString) {
formatString = formatString == null ? ERXTimestampFormatter.DEFAULT_PATTERN : formatString;
formatString = localizedStringForKeyWithDefault(formatString);
Format result = _dateFormatters.get(formatString);
if (result == null) {
Locale current = locale();
NSTimestampFormatter formatter = new NSTimestampFormatter(formatString, new DateFormatSymbols(current));
result = formatter;
_dateFormatters.put(formatString, result);
}
return result;
}
Aggregations