Added timezone usage to FormatUtils #551

This commit is contained in:
Rsl1122 2018-04-01 14:21:49 +03:00
parent 024a0ab62e
commit 6424fe4a28

View File

@ -11,6 +11,7 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
/**
* @author Rsl1122
@ -70,9 +71,12 @@ public class FormatUtils {
}
private static String format(long epochMs, String format) {
boolean useServerTime = Settings.USE_SERVER_TIME.isTrue();
String locale = Settings.LOCALE.toString();
Locale usedLocale = locale.equalsIgnoreCase("default") ? Locale.ENGLISH : Locale.forLanguageTag(locale);
SimpleDateFormat dateFormat = new SimpleDateFormat(format, usedLocale);
TimeZone timeZone = useServerTime ? TimeZone.getDefault() : TimeZone.getTimeZone("GMT");
dateFormat.setTimeZone(timeZone);
return dateFormat.format(epochMs);
}