forked from I2P_Developers/i2p.i2p
Utils: Move new getSystemTimeZone() from DataHelper to SystemVersion,
which is a better place for it.
This commit is contained in:
@ -31,6 +31,7 @@ import net.i2p.data.DataHelper;
|
|||||||
import net.i2p.data.Hash;
|
import net.i2p.data.Hash;
|
||||||
import net.i2p.util.Log;
|
import net.i2p.util.Log;
|
||||||
import net.i2p.util.SecureFile;
|
import net.i2p.util.SecureFile;
|
||||||
|
import net.i2p.util.SystemVersion;
|
||||||
import net.i2p.util.Translate;
|
import net.i2p.util.Translate;
|
||||||
|
|
||||||
import org.klomp.snark.I2PSnarkUtil;
|
import org.klomp.snark.I2PSnarkUtil;
|
||||||
@ -2802,7 +2803,7 @@ public class I2PSnarkServlet extends BasicServlet {
|
|||||||
}
|
}
|
||||||
long dat = meta.getCreationDate();
|
long dat = meta.getCreationDate();
|
||||||
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||||
fmt.setTimeZone(DataHelper.getSystemTimeZone(_context));
|
fmt.setTimeZone(SystemVersion.getSystemTimeZone(_context));
|
||||||
if (dat > 0) {
|
if (dat > 0) {
|
||||||
String date = fmt.format(new Date(dat));
|
String date = fmt.format(new Date(dat));
|
||||||
buf.append("<tr><td>");
|
buf.append("<tr><td>");
|
||||||
|
@ -8,12 +8,12 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.i2p.I2PAppContext;
|
|
||||||
import net.i2p.data.DataHelper;
|
import net.i2p.data.DataHelper;
|
||||||
import net.i2p.data.Hash;
|
import net.i2p.data.Hash;
|
||||||
import net.i2p.util.Clock;
|
import net.i2p.util.Clock;
|
||||||
import net.i2p.util.Log;
|
import net.i2p.util.Log;
|
||||||
import net.i2p.util.SimpleTimer2;
|
import net.i2p.util.SimpleTimer2;
|
||||||
|
import net.i2p.util.SystemVersion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Count how often something happens with a particular peer and all peers.
|
* Count how often something happens with a particular peer and all peers.
|
||||||
@ -56,7 +56,7 @@ class ConnThrottler {
|
|||||||
_log = log;
|
_log = log;
|
||||||
// for logging
|
// for logging
|
||||||
_fmt = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM);
|
_fmt = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM);
|
||||||
_fmt.setTimeZone(DataHelper.getSystemTimeZone(I2PAppContext.getGlobalContext()));
|
_fmt.setTimeZone(SystemVersion.getSystemTimeZone());
|
||||||
new Cleaner();
|
new Cleaner();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ import static net.i2p.app.ClientAppState.*;
|
|||||||
import net.i2p.data.DataHelper;
|
import net.i2p.data.DataHelper;
|
||||||
import net.i2p.util.FileUtil;
|
import net.i2p.util.FileUtil;
|
||||||
import net.i2p.util.Log;
|
import net.i2p.util.Log;
|
||||||
|
import net.i2p.util.SystemVersion;
|
||||||
import net.i2p.util.TranslateReader;
|
import net.i2p.util.TranslateReader;
|
||||||
|
|
||||||
import org.cybergarage.xml.Node;
|
import org.cybergarage.xml.Node;
|
||||||
@ -233,7 +234,7 @@ public class NewsManager implements ClientApp {
|
|||||||
// Doesn't work if the date has a : in it, but SHORT hopefully does not
|
// Doesn't work if the date has a : in it, but SHORT hopefully does not
|
||||||
DateFormat fmt = DateFormat.getDateInstance(DateFormat.SHORT);
|
DateFormat fmt = DateFormat.getDateInstance(DateFormat.SHORT);
|
||||||
// the router sets the JVM time zone to UTC but saves the original here so we can get it
|
// 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));
|
||||||
try {
|
try {
|
||||||
Date date = fmt.parse(newsContent.substring(0, colon));
|
Date date = fmt.parse(newsContent.substring(0, colon));
|
||||||
entry.updated = date.getTime();
|
entry.updated = date.getTime();
|
||||||
|
@ -43,6 +43,7 @@ import net.i2p.util.PortMapper;
|
|||||||
import net.i2p.util.ReusableGZIPInputStream;
|
import net.i2p.util.ReusableGZIPInputStream;
|
||||||
import net.i2p.util.SecureFileOutputStream;
|
import net.i2p.util.SecureFileOutputStream;
|
||||||
import net.i2p.util.SSLEepGet;
|
import net.i2p.util.SSLEepGet;
|
||||||
|
import net.i2p.util.SystemVersion;
|
||||||
import net.i2p.util.Translate;
|
import net.i2p.util.Translate;
|
||||||
import net.i2p.util.VersionComparator;
|
import net.i2p.util.VersionComparator;
|
||||||
|
|
||||||
@ -589,7 +590,7 @@ class NewsFetcher extends UpdateRunner {
|
|||||||
return;
|
return;
|
||||||
DateFormat fmt = DateFormat.getDateInstance(DateFormat.SHORT);
|
DateFormat fmt = DateFormat.getDateInstance(DateFormat.SHORT);
|
||||||
// the router sets the JVM time zone to UTC but saves the original here so we can get it
|
// 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));
|
||||||
for (NewsEntry e : entries) {
|
for (NewsEntry e : entries) {
|
||||||
if (e.title == null || e.content == null)
|
if (e.title == null || e.content == null)
|
||||||
continue;
|
continue;
|
||||||
|
@ -16,6 +16,7 @@ import java.util.TreeMap;
|
|||||||
|
|
||||||
import net.i2p.data.DataHelper;
|
import net.i2p.data.DataHelper;
|
||||||
import net.i2p.router.util.EventLog;
|
import net.i2p.router.util.EventLog;
|
||||||
|
import net.i2p.util.SystemVersion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* /events.jsp
|
* /events.jsp
|
||||||
@ -188,7 +189,7 @@ public class EventLogHelper extends FormHandler {
|
|||||||
|
|
||||||
SimpleDateFormat fmt = (SimpleDateFormat) DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM);
|
SimpleDateFormat fmt = (SimpleDateFormat) DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM);
|
||||||
// the router sets the JVM time zone to UTC but saves the original here so we can get it
|
// 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));
|
||||||
|
|
||||||
List<Map.Entry<Long, String>> entries = new ArrayList<Map.Entry<Long, String>>(events.entrySet());
|
List<Map.Entry<Long, String>> entries = new ArrayList<Map.Entry<Long, String>>(events.entrySet());
|
||||||
Collections.reverse(entries);
|
Collections.reverse(entries);
|
||||||
|
@ -10,6 +10,7 @@ import net.i2p.app.ClientAppManager;
|
|||||||
import net.i2p.data.DataHelper;
|
import net.i2p.data.DataHelper;
|
||||||
import net.i2p.router.news.NewsEntry;
|
import net.i2p.router.news.NewsEntry;
|
||||||
import net.i2p.router.news.NewsManager;
|
import net.i2p.router.news.NewsManager;
|
||||||
|
import net.i2p.util.SystemVersion;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,7 +56,7 @@ public class NewsFeedHelper extends HelperBase {
|
|||||||
if (!entries.isEmpty()) {
|
if (!entries.isEmpty()) {
|
||||||
DateFormat fmt = DateFormat.getDateInstance(DateFormat.SHORT);
|
DateFormat fmt = DateFormat.getDateInstance(DateFormat.SHORT);
|
||||||
// the router sets the JVM time zone to UTC but saves the original here so we can get it
|
// the router sets the JVM time zone to UTC but saves the original here so we can get it
|
||||||
fmt.setTimeZone(DataHelper.getSystemTimeZone(ctx));
|
fmt.setTimeZone(SystemVersion.getSystemTimeZone(ctx));
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (NewsEntry entry : entries) {
|
for (NewsEntry entry : entries) {
|
||||||
if (i++ < start)
|
if (i++ < start)
|
||||||
|
@ -633,7 +633,7 @@ public class SummaryBarRenderer {
|
|||||||
buf.append("<ul>\n");
|
buf.append("<ul>\n");
|
||||||
DateFormat fmt = DateFormat.getDateInstance(DateFormat.SHORT);
|
DateFormat fmt = DateFormat.getDateInstance(DateFormat.SHORT);
|
||||||
// the router sets the JVM time zone to UTC but saves the original here so we can get it
|
// 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));
|
||||||
int i = 0;
|
int i = 0;
|
||||||
final int max = 2;
|
final int max = 2;
|
||||||
for (NewsEntry entry : entries) {
|
for (NewsEntry entry : entries) {
|
||||||
|
@ -3,8 +3,7 @@ package i2p.susi.dns;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
|
|
||||||
import net.i2p.I2PAppContext;
|
import net.i2p.util.SystemVersion;
|
||||||
import net.i2p.data.DataHelper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format a date in local time zone
|
* Format a date in local time zone
|
||||||
@ -17,7 +16,7 @@ public abstract class FormatDate
|
|||||||
static {
|
static {
|
||||||
DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
|
DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
|
||||||
// the router sets the JVM time zone to UTC but saves the original here so we can get it
|
// the router sets the JVM time zone to UTC but saves the original here so we can get it
|
||||||
fmt.setTimeZone(DataHelper.getSystemTimeZone(I2PAppContext.getGlobalContext()));
|
fmt.setTimeZone(SystemVersion.getSystemTimeZone());
|
||||||
_dateFormat = fmt;
|
_dateFormat = fmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,8 +41,8 @@ import java.util.Date;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import net.i2p.I2PAppContext;
|
|
||||||
import net.i2p.data.DataHelper;
|
import net.i2p.data.DataHelper;
|
||||||
|
import net.i2p.util.SystemVersion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* data structure to hold a single message, mostly used with folder view and sorting
|
* data structure to hold a single message, mostly used with folder view and sorting
|
||||||
@ -276,7 +276,7 @@ class Mail {
|
|||||||
DateFormat localDateFormatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
|
DateFormat localDateFormatter = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
|
||||||
DateFormat longLocalDateFormatter = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
|
DateFormat longLocalDateFormatter = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
|
||||||
// the router sets the JVM time zone to UTC but saves the original here so we can get it
|
// the router sets the JVM time zone to UTC but saves the original here so we can get it
|
||||||
TimeZone tz = DataHelper.getSystemTimeZone(I2PAppContext.getGlobalContext());
|
TimeZone tz = SystemVersion.getSystemTimeZone();
|
||||||
localDateFormatter.setTimeZone(tz);
|
localDateFormatter.setTimeZone(tz);
|
||||||
longLocalDateFormatter.setTimeZone(tz);
|
longLocalDateFormatter.setTimeZone(tz);
|
||||||
DateFormat mailDateFormatter = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z", Locale.ENGLISH );
|
DateFormat mailDateFormatter = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z", Locale.ENGLISH );
|
||||||
|
@ -37,7 +37,6 @@ import java.util.Iterator;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.TimeZone;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.zip.Deflater;
|
import java.util.zip.Deflater;
|
||||||
@ -1925,20 +1924,4 @@ public class DataHelper {
|
|||||||
}
|
}
|
||||||
return p.split(s, limit);
|
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -478,7 +478,7 @@ public class LogManager implements Flushable {
|
|||||||
if (!format.equals(""))
|
if (!format.equals(""))
|
||||||
fmt.applyPattern(format);
|
fmt.applyPattern(format);
|
||||||
// the router sets the JVM time zone to UTC but saves the original here so we can get it
|
// 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;
|
_dateFormatPattern = format;
|
||||||
_dateFormat = fmt;
|
_dateFormat = fmt;
|
||||||
return true;
|
return true;
|
||||||
|
@ -5,6 +5,9 @@ package net.i2p.util;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
|
import net.i2p.I2PAppContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Methods to find out what system we are running on
|
* Methods to find out what system we are running on
|
||||||
@ -202,4 +205,59 @@ public abstract class SystemVersion {
|
|||||||
maxMemory = 96*1024*1024l;
|
maxMemory = 96*1024*1024l;
|
||||||
return maxMemory;
|
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());
|
||||||
|
|
||||||
|
}
|
||||||
|
****/
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user