From 9820abe11c0c037f50bb2f7ddbb0bd19646264dc Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 7 Apr 2017 10:29:52 +0300 Subject: juick-www: merge juick-spring-www i18n, drop thymeleaf --- .../juick/www/formatter/SpringDateFormatter.java | 44 ---------------------- 1 file changed, 44 deletions(-) delete mode 100644 juick-spring-www/src/main/java/com/juick/www/formatter/SpringDateFormatter.java (limited to 'juick-spring-www/src/main/java/com/juick/www/formatter') 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 { - @Resource - private MessageSource messageSource; - private ConcurrentMap 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); - } -} -- cgit v1.2.3