aboutsummaryrefslogtreecommitdiff
path: root/juick-spring-www/src/main/java/com/juick/www/formatter
diff options
context:
space:
mode:
Diffstat (limited to 'juick-spring-www/src/main/java/com/juick/www/formatter')
-rw-r--r--juick-spring-www/src/main/java/com/juick/www/formatter/SpringDateFormatter.java44
1 files changed, 0 insertions, 44 deletions
diff --git a/juick-spring-www/src/main/java/com/juick/www/formatter/SpringDateFormatter.java b/juick-spring-www/src/main/java/com/juick/www/formatter/SpringDateFormatter.java
deleted file mode 100644
index bbc776c24..000000000
--- a/juick-spring-www/src/main/java/com/juick/www/formatter/SpringDateFormatter.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package com.juick.www.formatter;
-
-import com.juick.util.DateFormatter;
-import org.springframework.context.MessageSource;
-import org.springframework.format.Formatter;
-
-import javax.annotation.Resource;
-import java.text.ParseException;
-import java.util.Date;
-import java.util.Locale;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- * Created by aalexeev on 11/22/16.
- */
-public class SpringDateFormatter implements Formatter<Date> {
- @Resource
- private MessageSource messageSource;
- private ConcurrentMap<Locale, com.juick.util.DateFormatter> formattersMap =
- new ConcurrentHashMap<>(4, 0.75f, 2); // MAX 4 languages and 4/2=2 threads for write
-
-
- @Override
- public Date parse(final String text, final Locale locale) throws ParseException {
- DateFormatter formatter = formattersMap.getOrDefault(
- locale, createFormatter(locale));
-
- return formatter.parse(text);
- }
-
- @Override
- public String print(final Date object, final Locale locale) {
- DateFormatter formatter = formattersMap.getOrDefault(
- locale, createFormatter(locale));
- return formatter.format(object);
- }
-
- private DateFormatter createFormatter(final Locale locale) {
- String pattern = messageSource.getMessage("date.format", null, locale);
-
- return new DateFormatter(pattern);
- }
-}