List of usage examples for java.util TimeZone setDefault
public static void setDefault(TimeZone zone)
From source file:org.imos.abos.netcdf.NetCDFfile.java
public NetCDFfile() { TimeZone.setDefault(tz); netcdfDate = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); TimeZone.setDefault(TimeZone.getTimeZone("GMT")); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); anchorTime = 0;/*from w w w.j a va 2s . c o m*/ try { java.util.Date ts = df.parse("1950-01-01 00:00:00"); anchorTime = ts.getTime(); } catch (ParseException pex) { logger.error(pex); } addTimeBnds = false; }
From source file:uk.ac.sanger.npg.picard.AlignmentFilterTest.java
public AlignmentFilterTest() { TimeZone.setDefault(TimeZone.getTimeZone("GMT")); }
From source file:org.eclipse.smarthome.binding.ntp.test.NtpOSGiTest.java
@BeforeClass public static void setUpClass() { /*// w w w.j a va 2s.c om * Store the initial system time zone and locale value, * so that we can restore them at the test end. */ systemTimeZone = TimeZone.getDefault(); locale = Locale.getDefault(); /* * Set new default time zone and locale, * which will be used during the tests execution. */ TimeZone.setDefault(TimeZone.getTimeZone(DEFAULT_TIME_ZONE_ID)); Locale.setDefault(Locale.US); }
From source file:hudson.plugins.timestamper.format.TimestampFormatterImplTest.java
/** *//*www. ja v a2 s .co m*/ @Before public void setUp() { systemDefaultTimeZone = TimeZone.getDefault(); // Set the time zone to get consistent results. TimeZone.setDefault(TimeZone.getTimeZone("GMT")); serialize = false; }
From source file:org.sipfoundry.voicemail.MessageDescriptorTest.java
public void testMessageDescriptorWriter() throws IOException { // Start with empty MessageDescriptor MessageDescriptor md = new MessageDescriptor(); String emptyXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "\n" + "<messagedescriptor>\n" + " <id/>\n" + " <from/>\n" + " <durationsecs/>\n" + " <timestamp/>\n" + " <subject/>\n" + " <priority>normal</priority>\n" + "</messagedescriptor>\n"; MessageDescriptorWriter mdw = new MessageDescriptorWriter(); File tempFile;/*from w ww. j a v a2 s. com*/ tempFile = File.createTempFile("MessageDescriptorTest", ".xml", m_testdir); mdw.writeObject(md, tempFile); assertTrue(tempFile.exists()); String contents = org.apache.commons.io.FileUtils.readFileToString(tempFile); assertEquals(emptyXml, contents); // Now set a priority and an Id String normalXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "\n" + "<messagedescriptor>\n" + " <id>woof@dog</id>\n" + " <from/>\n" + " <durationsecs/>\n" + " <timestamp/>\n" + " <subject/>\n" + " <priority>normal</priority>\n" + "</messagedescriptor>\n"; md.setId("woof@dog"); md.setPriority(Priority.NORMAL); tempFile.delete(); mdw.writeObject(md, tempFile); assertTrue(tempFile.exists()); contents = org.apache.commons.io.FileUtils.readFileToString(tempFile); assertEquals(normalXml, contents); // Now add a from address (watch the escaping!) String fromXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "\n" + "<messagedescriptor>\n" + " <id>woof@dog</id>\n" + " <from>\"Andy Spitzer\" <sip:woof@pingtel.com;dog=yes>;fluffy</from>\n" + " <durationsecs/>\n" + " <timestamp/>\n" + " <subject/>\n" + " <priority>normal</priority>\n" + "</messagedescriptor>\n"; md.setFromUri("\"Andy Spitzer\" <sip:woof@pingtel.com;dog=yes>;fluffy"); tempFile.delete(); mdw.writeObject(md, tempFile); assertTrue(tempFile.exists()); contents = org.apache.commons.io.FileUtils.readFileToString(tempFile); assertEquals(fromXml, contents); // Now add a timestamp String timeXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "\n" + "<messagedescriptor>\n" + " <id>woof@dog</id>\n" + " <from>\"Andy Spitzer\" <sip:woof@pingtel.com;dog=yes>;fluffy</from>\n" + " <durationsecs/>\n" + " <timestamp>Tue, 10-Jun-1997 12:00:00 AM EDT</timestamp>\n" + " <subject/>\n" + " <priority>normal</priority>\n" + "</messagedescriptor>\n"; TimeZone.setDefault(TimeZone.getTimeZone("America/New_York")); long timestamp = 865915200L * 1000; // Happy Birthday, Alex! md.setTimestamp(timestamp); tempFile.delete(); mdw.writeObject(md, tempFile); assertTrue(tempFile.exists()); contents = org.apache.commons.io.FileUtils.readFileToString(tempFile); assertEquals(timeXml, contents); tempFile.delete(); }
From source file:org.wso2.bps.samples.processcleanup.CleanupExecutor.java
/** * main method//from w w w . ja v a2s .c om * * @param args * @throws Exception */ public static void main(String[] args) throws Exception { initializeDBConnection(); query = new DBQuery(databaseURL, bpsHome); TimeZone.setDefault(TimeZone.getTimeZone(getProperty(CleanupConstants.TIME_ZONE))); System.out.println("\n=============ATTENTION=================\n" + "This tool deletes selected process versions and optionally all corresponding process instances.\n" + "Hence take backups of DB before executing this tool.\n" + "Also read configuration information from the docs before running the tool.\n" + "======================================="); System.out.println("\nInsert option number to list non-active BPEL packages"); System.out.println("1. List All"); System.out.println("2. Search and List by Process Name"); System.out.println("3. Exit"); int userInput[] = getValidUserInput(1, 3, CleanupConstants.ENTER_OPTION_NUMBER); String name = null; switch (userInput[0]) { case 3: System.exit(0); break; case 2: System.out.println("Please Enter Process Name:"); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); name = br.readLine().trim(); default: System.out.println("Initialize JDBC Connection\n"); try { //listing out the deletable process list in the console System.out.println("List of Non-Active BPEL Packages\n"); System.out.println(String.format(" %-9s | %s", "Option #", "Package Name")); System.out.println("=========================================="); map = getDeletablePackageList(name); String[] list = map.keySet().toArray(new String[] {}); int deleteAllOption = list.length + 1; switch (list.length) { case 0: System.out.println("*** No Packages Found ***"); System.out.println("=========================================="); break; case 1: System.out.println("=========================================="); break; default: System.out.println("=========================================="); String id = String.format("%9d", deleteAllOption); System.out.println(String.format("%-10s | %s", id, "Delete All")); break; } String id = String.format("%9d", 0); System.out.println(String.format("%-10s | %s", id, "Exit")); //Get user input with multiple packages to delete at once int options[] = getValidUserInput(0, deleteAllOption, CleanupConstants.OPTION_NUMBERS_TO_DELETE); if (options[0] == 0) { //if entered 0 system exits System.exit(0); } else if (options[0] == deleteAllOption) { //Delete all option for (String packageName : list) { deletePackages(packageName); } } else { //Delete several packages for (int op : options) { deletePackages(list[op - 1]); } } } catch (Exception e) { String errMsg = "Process deletion exception."; log.error(errMsg, e); } break; } }
From source file:hudson.plugins.timestamper.format.TimestampFormatterImplTest.java
/** */ @After public void tearDown() { TimeZone.setDefault(systemDefaultTimeZone); }
From source file:net.audumla.astronomy.algorithims.AstronomicalTest.java
@Test public void testDateConversion2() throws Exception { TimeZone.setDefault(TimeZone.getTimeZone("Australia/Melbourne")); java.util.Date date = new Date(); date = DateUtils.setYears(date, 2013); date = DateUtils.setMinutes(date, 0); date = DateUtils.setMonths(date, 0); date = DateUtils.setMilliseconds(date, 0); date = DateUtils.setSeconds(date, 0); date = DateUtils.setDays(date, 1);//from w ww .j a va 2 s.c o m date = DateUtils.setHours(date, 0); JulianDate cDate = new JulianDate(date); logger.debug("Algorithms: " + cDate.toDate() + " : " + cDate.toDate().getTime()); logger.debug("Algorithms: " + date + " : " + date.getTime()); Assert.assertEquals(cDate.toDate().getTime(), date.getTime(), 1100); }
From source file:io.cslinmiso.line.utils.Utility.java
/** * ?import java.util.Date; import java.text.SimpleDateFormat; ?? datebase ??datetime? *//*from w ww.ja va 2 s.co m*/ public static String getDateTime() { SimpleDateFormat sdFormat = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss"); TimeZone tz = TimeZone.getTimeZone("Asia/Taipei"); TimeZone.setDefault(tz); Date date = new Date(); String strDate = sdFormat.format(date); return strDate; }
From source file:plugins.Indynet.IndynetResolver.java
private JSONObject buildResolveObject(FreenetURI requestUri, String name) { Date date = new java.util.Date(); JSONObject obj = new JSONObject(); obj.put("keyType", requestUri.getKeyType()); obj.put("requestKey", requestUri.toString().split("/")[0]); TimeZone.setDefault(TimeZone.getTimeZone("UTC")); Timestamp now = new Timestamp(date.getTime()); obj.put("regTime", now.toLocalDateTime().toString()); return obj;/*w w w . j ava2 s. c o m*/ }