List of usage examples for java.util TimeZone setDefault
public static void setDefault(TimeZone zone)
From source file:org.jfree.data.time.WeekTest.java
/** * Some checks for the getFirstMillisecond() method. *///from w w w . j a v a 2s .c om @Test public void testGetFirstMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Week w = new Week(3, 1970); assertEquals(946800000L, w.getFirstMillisecond()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); }
From source file:org.jfree.data.time.MinuteTest.java
/** * Some checks for the getEnd() method./*w ww . j av a 2 s. c o m*/ */ @Test public void testGetEnd() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/Rome")); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.JANUARY, 16, 3, 47, 59); cal.set(Calendar.MILLISECOND, 999); Minute m = new Minute(47, 3, 16, 1, 2006); assertEquals(cal.getTime(), m.getEnd()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); }
From source file:org.transitime.applications.GtfsFileProcessor.java
/** * Sets timezone for the application so that times and dates will be written * correctly to the database. This is especially important for calendar * dates. Needs to be called before the db is first accessed in order to * have an effect with postgres (with mysql can do so afterwards, which is * strange). So needs to be done before GtfsData() object is constructed. * <p>/* w ww . j a v a2 s . co m*/ * The timezone string is obtained from the agency.txt GTFS file. * * @param gtfsDirectoryName Where to find the GTFS files */ private void setTimezone(String gtfsDirectoryName) { // Read in the agency.txt GTFS data from file GtfsAgencyReader agencyReader = new GtfsAgencyReader(gtfsDirectoryName); List<GtfsAgency> gtfsAgencies = agencyReader.get(); if (gtfsAgencies.isEmpty()) { logger.error("Could not read in {}/agency.txt file, which is " + "needed for createDateFormatter()", gtfsDirectoryName); System.exit(-1); } String timezoneName = gtfsAgencies.get(0).getAgencyTimezone(); // Set system timezone so that dates and times will be written to db // properly TimeZone.setDefault(TimeZone.getTimeZone(timezoneName)); logger.info("Set at beginning default timezone to {}", timezoneName); }
From source file:org.jfree.data.time.TimeSeriesCollectionTest.java
/** * This method provides a check for the bounds calculated using the * {@link DatasetUtilities#findDomainBounds(org.jfree.data.xy.XYDataset, * java.util.List, boolean)} method.//from w ww. j av a 2 s . co m */ @Test public void testFindDomainBounds() { TimeSeriesCollection dataset = new TimeSeriesCollection(); List visibleSeriesKeys = new java.util.ArrayList(); Range r = DatasetUtilities.findDomainBounds(dataset, visibleSeriesKeys, true); assertNull(r); TimeSeries s1 = new TimeSeries("S1"); dataset.addSeries(s1); visibleSeriesKeys.add("S1"); r = DatasetUtilities.findDomainBounds(dataset, visibleSeriesKeys, true); assertNull(r); // store the current time zone TimeZone saved = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/Paris")); s1.add(new Year(2008), 8.0); r = DatasetUtilities.findDomainBounds(dataset, visibleSeriesKeys, true); assertEquals(1199142000000.0, r.getLowerBound(), EPSILON); assertEquals(1230764399999.0, r.getUpperBound(), EPSILON); TimeSeries s2 = new TimeSeries("S2"); dataset.addSeries(s2); s2.add(new Year(2009), 9.0); s2.add(new Year(2010), 10.0); r = DatasetUtilities.findDomainBounds(dataset, visibleSeriesKeys, true); assertEquals(1199142000000.0, r.getLowerBound(), EPSILON); assertEquals(1230764399999.0, r.getUpperBound(), EPSILON); visibleSeriesKeys.add("S2"); r = DatasetUtilities.findDomainBounds(dataset, visibleSeriesKeys, true); assertEquals(1199142000000.0, r.getLowerBound(), EPSILON); assertEquals(1293836399999.0, r.getUpperBound(), EPSILON); // restore the default time zone TimeZone.setDefault(saved); }
From source file:org.jfree.data.time.junit.MonthTest.java
/** * Some checks for the getLastMillisecond() method. *///from w w w. j av a2 s . com public void testGetLastMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Month m = new Month(3, 1970); assertEquals(7772399999L, m.getLastMillisecond()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); }
From source file:org.jfree.data.time.junit.DayTest.java
/** * Some checks for the getLastMillisecond() method. *//*from ww w .j a v a 2s . c o m*/ public void testGetLastMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); Day d = new Day(1, 1, 1970); assertEquals(82799999L, d.getLastMillisecond()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); }
From source file:org.jfree.data.time.junit.MinuteTest.java
/** * Some checks for the getStart() method. */// ww w. j av a2 s. c om public void testGetStart() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/Rome")); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.JANUARY, 16, 3, 47, 0); cal.set(Calendar.MILLISECOND, 0); Minute m = new Minute(47, 3, 16, 1, 2006); assertEquals(cal.getTime(), m.getStart()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); }
From source file:com.cyberway.issue.crawler.Heritrix.java
/** * Launch program./*from w ww. j a v a 2s. c om*/ * Optionally will launch a web server to host UI. Will also register * Heritrix MBean with first found JMX Agent (Usually the 1.5.0 JVM * Agent). * * @param args Command line arguments. * @throws Exception */ public static void main(String[] args) throws Exception { Heritrix.commandLine = true; // Set timezone here. Would be problematic doing it if we're running // inside in a container. TimeZone.setDefault(TimeZone.getTimeZone("GMT")); File startLog = new File(getHeritrixHome(), STARTLOG); Heritrix.out = new PrintWriter( isDevelopment() ? System.out : new PrintStream(new FileOutputStream(startLog))); try { containerInitialization(); String status = doCmdLineArgs(args); if (status != null) { Heritrix.out.println(status); } } catch (Exception e) { // Show any exceptions in STARTLOG. e.printStackTrace(Heritrix.out); throw e; } finally { // If not development, close the file that signals the wrapper // script that we've started. Otherwise, just flush it; if in // development, the output is probably a console. if (!isDevelopment()) { if (Heritrix.out != null) { Heritrix.out.close(); } System.out.println("Heritrix version: " + Heritrix.getVersion()); } else { if (Heritrix.out != null) { Heritrix.out.flush(); } } } }
From source file:org.jfree.data.time.junit.MinuteTest.java
/** * Some checks for the getEnd() method./*from w ww. j a v a 2 s .c om*/ */ public void testGetEnd() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); TimeZone savedZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("Europe/Rome")); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.JANUARY, 16, 3, 47, 59); cal.set(Calendar.MILLISECOND, 999); Minute m = new Minute(47, 3, 16, 1, 2006); assertEquals(cal.getTime(), m.getEnd()); Locale.setDefault(saved); TimeZone.setDefault(savedZone); }
From source file:org.alfresco.repo.search.impl.solr.SolrQueryHTTPClientTest.java
@Test public void testBuildFacetIntervalQuery() throws UnsupportedEncodingException { TimeZone defaultTimeZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("UTC")); SearchParameters params = new SearchParameters(); params.setSearchTerm("bob"); IntervalSet intervalSet = new IntervalSet("8", "12", null, null, null); params.setInterval(new IntervalParameters(new HashSet(Arrays.asList(intervalSet)), null)); StringBuilder urlBuilder = new StringBuilder(); client.buildFacetIntervalParameters(params, encoder, urlBuilder); String url = urlBuilder.toString(); assertNotNull(url);/* w ww. j a v a2 s . c om*/ assertTrue(url.contains("&facet=true")); assertTrue(url.contains(encoder.encode("{!afts}[8,12]", "UTF-8"))); intervalSet = new IntervalSet("1", "10", "numbers", false, true); params.setInterval(new IntervalParameters(new HashSet(Arrays.asList(intervalSet)), null)); urlBuilder = new StringBuilder(); client.buildFacetIntervalParameters(params, encoder, urlBuilder); url = urlBuilder.toString(); assertNotNull(url); assertTrue(url.contains("&facet=true")); assertTrue(url.contains(encoder.encode("{!afts key=numbers}(1,10]", "UTF-8"))); List<Interval> intervalList = Arrays.asList(new Interval("cm:price", "Price", null), new Interval("cm:created", "Created", new HashSet(Arrays.asList(new IntervalSet("2015", "2016-12", "special", false, true))))); params.setInterval(new IntervalParameters(new HashSet(Arrays.asList(intervalSet)), intervalList)); urlBuilder = new StringBuilder(); client.buildFacetIntervalParameters(params, encoder, urlBuilder); url = urlBuilder.toString(); assertNotNull(url); assertTrue(url.contains("&facet=true")); assertTrue(url.contains(encoder.encode("{!afts key=numbers}(1,10]", "UTF-8"))); assertTrue(url.contains(encoder.encode("{!key=Price}cm:price", "UTF-8"))); assertTrue(url.contains(encoder.encode("{!key=Created}cm:created", "UTF-8"))); assertTrue(url.contains(encoder.encode("f.cm:created.facet.interval.set", "UTF-8"))); assertTrue(url.contains(encoder.encode("{!afts key=numbers}", "UTF-8"))); assertTrue(url.contains(encoder.encode("(2015-12-31T23:59:59.999Z", "UTF-8"))); assertTrue(url.contains(encoder.encode("2016-12-31T23:59:59.999Z]", "UTF-8"))); TimeZone.setDefault(defaultTimeZone); }