Changeset 6fb0692


Ignore:
Timestamp:
Nov 16, 2015 8:04:15 PM (5 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
679fe9b
Parents:
38a1a96
Message:

Centralize time zone code in DataHelper?
NewsManager? should be a ClientApp?, not a RouterApp?

Files:
11 edited

Legend:

Unmodified
Added
Removed
  • apps/i2psnark/java/src/org/klomp/snark/web/I2PSnarkServlet.java

    r38a1a96 r6fb0692  
    1919import java.util.Map;
    2020import java.util.Set;
    21 import java.util.TimeZone;
    2221import java.util.TreeMap;
    2322
     
    28022801                long dat = meta.getCreationDate();
    28032802                SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    2804                 String systemTimeZone = _context.getProperty("i2p.systemTimeZone");
    2805                 if (systemTimeZone != null)
    2806                     fmt.setTimeZone(TimeZone.getTimeZone(systemTimeZone));
     2803                fmt.setTimeZone(DataHelper.getSystemTimeZone(_context));
    28072804                if (dat > 0) {
    28082805                    String date = fmt.format(new Date(dat));
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/ConnThrottler.java

    r38a1a96 r6fb0692  
    88import java.util.List;
    99import java.util.Map;
    10 import java.util.TimeZone;
    1110
    1211import net.i2p.I2PAppContext;
     
    5857        // for logging
    5958        _fmt = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM);
    60         String systemTimeZone = I2PAppContext.getGlobalContext().getProperty("i2p.systemTimeZone");
    61         if (systemTimeZone != null)
    62             _fmt.setTimeZone(TimeZone.getTimeZone(systemTimeZone));
     59        _fmt.setTimeZone(DataHelper.getSystemTimeZone(I2PAppContext.getGlobalContext()));
    6360        new Cleaner();
    6461    }
  • apps/routerconsole/java/src/net/i2p/router/news/NewsManager.java

    r38a1a96 r6fb0692  
    1111import java.util.Date;
    1212import java.util.List;
    13 import java.util.TimeZone;
    1413
    1514import net.i2p.I2PAppContext;
     15import net.i2p.app.ClientApp;
    1616import net.i2p.app.ClientAppManager;
    1717import net.i2p.app.ClientAppState;
    1818import static net.i2p.app.ClientAppState.*;
    19 import net.i2p.router.app.RouterApp;
     19import net.i2p.data.DataHelper;
    2020import net.i2p.util.FileUtil;
    2121import net.i2p.util.Log;
     
    3131 *  @since 0.9.23
    3232 */
    33 public class NewsManager implements RouterApp {
     33public class NewsManager implements ClientApp {
    3434
    3535    private final I2PAppContext _context;
     
    234234                    DateFormat fmt = DateFormat.getDateInstance(DateFormat.SHORT);
    235235                    // the router sets the JVM time zone to UTC but saves the original here so we can get it
    236                     String systemTimeZone = _context.getProperty("i2p.systemTimeZone");
    237                     if (systemTimeZone != null)
    238                         fmt.setTimeZone(TimeZone.getTimeZone(systemTimeZone));
     236                    fmt.setTimeZone(DataHelper.getSystemTimeZone(_context));
    239237                    try {
    240238                        Date date = fmt.parse(newsContent.substring(0, colon));
  • apps/routerconsole/java/src/net/i2p/router/update/NewsFetcher.java

    r38a1a96 r6fb0692  
    2020import java.util.Map;
    2121import java.util.StringTokenizer;
    22 import java.util.TimeZone;
    2322
    2423import net.i2p.app.ClientAppManager;
     
    580579            DateFormat fmt = DateFormat.getDateInstance(DateFormat.SHORT);
    581580            // the router sets the JVM time zone to UTC but saves the original here so we can get it
    582             String systemTimeZone = _context.getProperty("i2p.systemTimeZone");
    583             if (systemTimeZone != null)
    584                 fmt.setTimeZone(TimeZone.getTimeZone(systemTimeZone));
     581            fmt.setTimeZone(DataHelper.getSystemTimeZone(_context));
    585582            for (NewsEntry e : entries) {
    586583                if (e.title == null || e.content == null)
  • apps/routerconsole/java/src/net/i2p/router/web/EventLogHelper.java

    r38a1a96 r6fb0692  
    1313import java.util.List;
    1414import java.util.Map;
    15 import java.util.TimeZone;
    1615import java.util.TreeMap;
    1716
     
    190189        SimpleDateFormat fmt = (SimpleDateFormat) DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM);
    191190        // the router sets the JVM time zone to UTC but saves the original here so we can get it
    192         String systemTimeZone = _context.getProperty("i2p.systemTimeZone");
    193         if (systemTimeZone != null)
    194             fmt.setTimeZone(TimeZone.getTimeZone(systemTimeZone));
     191        fmt.setTimeZone(DataHelper.getSystemTimeZone(_context));
    195192
    196193        List<Map.Entry<Long, String>> entries = new ArrayList<Map.Entry<Long, String>>(events.entrySet());
  • apps/routerconsole/java/src/net/i2p/router/web/NewsFeedHelper.java

    r38a1a96 r6fb0692  
    55import java.util.Date;
    66import java.util.List;
    7 import java.util.TimeZone;
    87
    98import net.i2p.I2PAppContext;
     
    5756            DateFormat fmt = DateFormat.getDateInstance(DateFormat.SHORT);
    5857            // the router sets the JVM time zone to UTC but saves the original here so we can get it
    59             String systemTimeZone = ctx.getProperty("i2p.systemTimeZone");
    60             if (systemTimeZone != null)
    61                 fmt.setTimeZone(TimeZone.getTimeZone(systemTimeZone));
     58            fmt.setTimeZone(DataHelper.getSystemTimeZone(ctx));
    6259            int i = 0;
    6360            for (NewsEntry entry : entries) {
  • apps/routerconsole/java/src/net/i2p/router/web/SummaryBarRenderer.java

    r38a1a96 r6fb0692  
    1010import java.util.List;
    1111import java.util.Map;
    12 import java.util.TimeZone;
    1312
    1413import net.i2p.app.ClientAppManager;
     
    635634                DateFormat fmt = DateFormat.getDateInstance(DateFormat.SHORT);
    636635                // the router sets the JVM time zone to UTC but saves the original here so we can get it
    637                 String systemTimeZone = _context.getProperty("i2p.systemTimeZone");
    638                 if (systemTimeZone != null)
    639                     fmt.setTimeZone(TimeZone.getTimeZone(systemTimeZone));
     636                fmt.setTimeZone(DataHelper.getSystemTimeZone(_context));
    640637                int i = 0;
    641638                final int max = 2;
  • apps/susidns/src/java/src/i2p/susi/dns/FormatDate.java

    r38a1a96 r6fb0692  
    33import java.util.Date;
    44import java.text.DateFormat;
    5 import java.util.TimeZone;
    65
    76import net.i2p.I2PAppContext;
     7import net.i2p.data.DataHelper;
    88
    99/**
     
    1818        DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
    1919        // the router sets the JVM time zone to UTC but saves the original here so we can get it
    20         String systemTimeZone = I2PAppContext.getGlobalContext().getProperty("i2p.systemTimeZone");
    21         if (systemTimeZone != null)
    22                 fmt.setTimeZone(TimeZone.getTimeZone(systemTimeZone));
     20        fmt.setTimeZone(DataHelper.getSystemTimeZone(I2PAppContext.getGlobalContext()));
    2321        _dateFormat = fmt;
    2422    }
  • apps/susimail/src/src/i2p/susi/webmail/Mail.java

    r38a1a96 r6fb0692  
    277277                DateFormat longLocalDateFormatter = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
    278278                // the router sets the JVM time zone to UTC but saves the original here so we can get it
    279                 String systemTimeZone = I2PAppContext.getGlobalContext().getProperty("i2p.systemTimeZone");
    280                 if (systemTimeZone != null) {
    281                         TimeZone tz = TimeZone.getTimeZone(systemTimeZone);
    282                         localDateFormatter.setTimeZone(tz);
    283                         longLocalDateFormatter.setTimeZone(tz);
    284                 }
     279                TimeZone tz = DataHelper.getSystemTimeZone(I2PAppContext.getGlobalContext());
     280                localDateFormatter.setTimeZone(tz);
     281                longLocalDateFormatter.setTimeZone(tz);
    285282                DateFormat mailDateFormatter = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z", Locale.ENGLISH );
    286283               
  • core/java/src/net/i2p/data/DataHelper.java

    r38a1a96 r6fb0692  
    3838import java.util.Map;
    3939import java.util.Properties;
     40import java.util.TimeZone;
    4041import java.util.concurrent.ConcurrentHashMap;
    4142import java.util.regex.Pattern;
     
    19251926        return p.split(s, limit);
    19261927    }
     1928
     1929    /**
     1930     *  The system's time zone, which is probably different from the
     1931     *  JVM time zone, because Router changes the JVM default to GMT.
     1932     *  It saves the old default in the context properties where we can get it.
     1933     *  Use this to format a time in local time zone with DateFormat.setTimeZone().
     1934     *
     1935     *  @return non-null
     1936     *  @since 0.9.24
     1937     */
     1938    public static TimeZone getSystemTimeZone(I2PAppContext ctx) {
     1939        String systemTimeZone = ctx.getProperty("i2p.systemTimeZone");
     1940        if (systemTimeZone != null)
     1941            return TimeZone.getTimeZone(systemTimeZone);
     1942        return TimeZone.getDefault();
     1943    }
    19271944}
  • core/java/src/net/i2p/util/LogManager.java

    r38a1a96 r6fb0692  
    2323import java.util.Queue;
    2424import java.util.Set;
    25 import java.util.TimeZone;
    2625import java.util.concurrent.ConcurrentHashMap;
    2726import java.util.concurrent.LinkedBlockingQueue;
     
    480479                fmt.applyPattern(format);
    481480            // the router sets the JVM time zone to UTC but saves the original here so we can get it
    482             String systemTimeZone = _context.getProperty("i2p.systemTimeZone");
    483             if (systemTimeZone != null)
    484                 fmt.setTimeZone(TimeZone.getTimeZone(systemTimeZone));
     481            fmt.setTimeZone(DataHelper.getSystemTimeZone(_context));
    485482            _dateFormatPattern = format;
    486483            _dateFormat = fmt;
Note: See TracChangeset for help on using the changeset viewer.