Utils: Move new getSystemTimeZone() from DataHelper to SystemVersion,

which is a better place for it.
This commit is contained in:
zzz
2015-12-06 16:28:14 +00:00
parent 5a7fc3f7f4
commit fdc160cf1d
12 changed files with 76 additions and 31 deletions

View File

@@ -37,7 +37,6 @@ import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.TimeZone;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Pattern;
import java.util.zip.Deflater;
@@ -1925,20 +1924,4 @@ public class DataHelper {
}
return p.split(s, limit);
}
/**
* The system's time zone, which is probably different from the
* JVM time zone, because Router changes the JVM default to GMT.
* It saves the old default in the context properties where we can get it.
* Use this to format a time in local time zone with DateFormat.setTimeZone().
*
* @return non-null
* @since 0.9.24
*/
public static TimeZone getSystemTimeZone(I2PAppContext ctx) {
String systemTimeZone = ctx.getProperty("i2p.systemTimeZone");
if (systemTimeZone != null)
return TimeZone.getTimeZone(systemTimeZone);
return TimeZone.getDefault();
}
}

View File

@@ -478,7 +478,7 @@ public class LogManager implements Flushable {
if (!format.equals(""))
fmt.applyPattern(format);
// the router sets the JVM time zone to UTC but saves the original here so we can get it
fmt.setTimeZone(DataHelper.getSystemTimeZone(_context));
fmt.setTimeZone(SystemVersion.getSystemTimeZone(_context));
_dateFormatPattern = format;
_dateFormat = fmt;
return true;

View File

@@ -5,6 +5,9 @@ package net.i2p.util;
*/
import java.lang.reflect.Field;
import java.util.TimeZone;
import net.i2p.I2PAppContext;
/**
* Methods to find out what system we are running on
@@ -202,4 +205,59 @@ public abstract class SystemVersion {
maxMemory = 96*1024*1024l;
return maxMemory;
}
/**
* The system's time zone, which is probably different from the
* JVM time zone, because Router changes the JVM default to GMT.
* It saves the old default in the context properties where we can get it.
* Use this to format a time in local time zone with DateFormat.setTimeZone().
*
* @return non-null
* @since 0.9.24
*/
public static TimeZone getSystemTimeZone() {
return getSystemTimeZone(I2PAppContext.getGlobalContext());
}
/**
* The system's time zone, which is probably different from the
* JVM time zone, because Router changes the JVM default to GMT.
* It saves the old default in the context properties where we can get it.
* Use this to format a time in local time zone with DateFormat.setTimeZone().
*
* @return non-null
* @since 0.9.24
*/
public static TimeZone getSystemTimeZone(I2PAppContext ctx) {
String systemTimeZone = ctx.getProperty("i2p.systemTimeZone");
if (systemTimeZone != null)
return TimeZone.getTimeZone(systemTimeZone);
return TimeZone.getDefault();
}
/**
* @since 0.9.24
*/
/****
public static void main(String[] args) {
System.out.println("64 bit : " + is64Bit());
System.out.println("Java 6 : " + isJava6());
System.out.println("Java 7 : " + isJava7());
System.out.println("Java 8 : " + isJava8());
System.out.println("Java 9 : " + isJava9());
System.out.println("Android : " + isAndroid());
if (isAndroid())
System.out.println(" Version: " + getAndroidVersion());
System.out.println("Apache : " + isApache());
System.out.println("ARM : " + isARM());
System.out.println("Mac : " + isMac());
System.out.println("Gentoo : " + isGentoo());
System.out.println("GNU : " + isGNU());
System.out.println("Windows : " + isWindows());
System.out.println("Wrapper : " + hasWrapper());
System.out.println("x86 : " + isX86());
System.out.println("Max mem : " + getMaxMemory());
}
****/
}