List of usage examples for java.util TimeZone setDefault
public static void setDefault(TimeZone zone)
From source file:com.bc.fiduceo.db.Storage.java
private Driver createDriver(BasicDataSource dataSource) { // ensure all dates are interpreted as UTC TimeZone.setDefault(TimeZone.getTimeZone("UTC")); final String dbUrl = dataSource.getUrl().toLowerCase(); final DriverUtils syDriverUtils = new DriverUtils(); return syDriverUtils.getDriver(dbUrl); }
From source file:com.groupdocs.HomeController.java
@RequestMapping(value = "/view", method = RequestMethod.GET) public String index(Model model, HttpServletRequest request, HttpServletResponse response, @RequestParam(value = "fileId", required = false) String fileId, @RequestParam(value = "fileUrl", required = false) String fileUrl, @RequestParam(value = "filePath", required = false) String filePath, @RequestParam(value = "tokenId", required = false) String tokenId, @RequestParam(value = "userName", required = false) final String userName) throws Exception { if (annotationHandler == null) { TimeZone.setDefault(TimeZone.getTimeZone("Europe/Vilnius")); // Application path String appPath = "http://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath(); // File storage path String basePath = applicationConfig.getBasePath(); // File license path String licensePath = applicationConfig.getLicensePath(); // INITIALIZE GroupDocs Java Annotation Object ServiceConfiguration config = new ServiceConfiguration(appPath, basePath, licensePath, Boolean.FALSE, applicationConfig.getWidth()); annotationHandler = new AnnotationHandler(config); // InputDataHandler.setInputDataHandler(new CustomInputDataHandler(config)); }/* w w w.j a va 2s . com*/ // Setting header in jsp page model.addAttribute("groupdocsHeader", annotationHandler.getHeader()); // Initialization of Viewer with document from this path final GroupDocsPath groupDocsFilePath; if (fileId != null && !fileId.isEmpty()) { groupDocsFilePath = new FileId(fileId); } else if (filePath != null && !filePath.isEmpty()) { groupDocsFilePath = new FilePath(filePath, annotationHandler.getConfiguration()); } else if (fileUrl != null && !fileUrl.isEmpty()) { groupDocsFilePath = new FileUrl(fileUrl); } else if (tokenId != null && !tokenId.isEmpty()) { TokenId tki = new TokenId(tokenId); if (tki.isExpired()) { groupDocsFilePath = null; } else { groupDocsFilePath = tki; } } else { groupDocsFilePath = null; } final String userGuid = annotationHandler.addCollaborator(userName, groupDocsFilePath.getPath(), AccessRights.All, getIntFromColor(Color.black)); HashMap<String, String> params = new HashMap<String, String>() { { // You can skip parameters which have default value put("filePath", groupDocsFilePath.getPath()); // Default value: empty string put("width", Integer.toString(applicationConfig.getWidth())); // Default value: 800 put("height", Integer.toString(applicationConfig.getHeight())); // Default value: 600 put("quality", "75"); // Default value: 90 put("enableRightClickMenu", "true"); // Default value: true put("showHeader", Boolean.toString(applicationConfig.getShowHeader())); // Default value: true put("showZoom", Boolean.toString(applicationConfig.getShowZoom())); // Default value: true put("showPaging", Boolean.toString(applicationConfig.getShowPaging())); // Default value: true put("showPrint", Boolean.toString(applicationConfig.getShowPrint())); // Default value: false put("showFileExplorer", "true"); // Default value: true put("showThumbnails", Boolean.toString(applicationConfig.getShowThumbnails())); // Default value: true put("openThumbnails", Boolean.toString(applicationConfig.getOpenThumbnails())); // Default value: false put("zoomToFitWidth", "false"); // Default value: false put("zoomToFitHeight", "false"); // Default value: false put("initialZoom", "100"); // Default value: 100 put("preloadPagesCount", "0"); // Default value: 0 put("enableSidePanel", "true"); // Default value: true put("strikeOutColor", ""); // Default value: empty string put("enabledTools", "255"); // Default value: 255 put("saveReplyOnFocusLoss", "false"); // Default value: false put("strikeoutMode", "0"); // Default value: 0 put("sideboarContainerSelector", "div.comments_sidebar_wrapper"); // Default value: div.comments_sidebar_wrapper put("usePageNumberInUrlHash", "false"); // Default value: false put("textSelectionSynchronousCalculation", "true"); // Default value: true put("variableHeightPageSupport", "true"); // Default value: true put("useJavaScriptDocumentDescription", "true"); // Default value: true put("isRightPanelEnabled", "true"); // Default value: true put("createMarkup", "true"); // Default value: true put("use_pdf", "true"); // Default value: true put("_mode", "annotatedDocument"); // Default value: annotatedDocument put("selectionContainerSelector", "[name='selection-content']"); // Default value: [name='selection-content'] put("graphicsContainerSelector", ".annotationsContainer"); // Default value: .annotationsContainer put("widgetId", "annotation-widget"); // Default value: annotation-widget put("userName", userName == null ? "Anonimous" : userName); put("userGuid", userGuid); // put("showFolderBrowser", Boolean.toString(applicationConfig.getShowFolderBrowser())); // Not used // put("showDownload", Boolean.toString(applicationConfig.getShowDownload())); // Not used // put("showSearch", Boolean.toString(applicationConfig.getShowSearch())); // Not used } }; model.addAttribute("groupdocsScripts", annotationHandler.getScripts(params)); model.addAttribute("width", applicationConfig.getWidth()); // It is for sample JSP (index.jsp) model.addAttribute("height", applicationConfig.getHeight()); // It is for sample JSP (index.jsp) return "index"; }
From source file:org.milyn.smooks.mule.RouterGeneralFunctionalTest.java
@Override protected void doSetUp() throws Exception { super.doSetUp(); TimeZone.setDefault(TimeZone.getTimeZone("EST")); Locale.setDefault(Locale.ENGLISH); FileUtils.deleteDirectory(routingTestDir); if (reportFile.exists()) { reportFile.delete();/*from w w w . jav a 2s .c om*/ } }
From source file:azkaban.execapp.AzkabanExecutorServer.java
/** * Azkaban using Jetty/*from w w w. jav a 2 s . co m*/ * * @param args * @throws IOException */ public static void main(String[] args) throws Exception { // Redirect all std out and err messages into log4j StdOutErrRedirect.redirectOutAndErrToLog(); logger.info("Starting Jetty Azkaban Executor..."); Props azkabanSettings = AzkabanServer.loadProps(args); if (azkabanSettings == null) { logger.error("Azkaban Properties not loaded."); logger.error("Exiting Azkaban Executor Server..."); return; } // Setup time zone if (azkabanSettings.containsKey(DEFAULT_TIMEZONE_ID)) { String timezone = azkabanSettings.getString(DEFAULT_TIMEZONE_ID); System.setProperty("user.timezone", timezone); TimeZone.setDefault(TimeZone.getTimeZone(timezone)); DateTimeZone.setDefault(DateTimeZone.forID(timezone)); logger.info("Setting timezone to " + timezone); } app = new AzkabanExecutorServer(azkabanSettings); Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { try { logTopMemoryConsumers(); } catch (Exception e) { logger.info(("Exception when logging top memory consumers"), e); } String host = app.getHost(); int port = app.getPort(); try { logger.info(String.format("Removing executor(host: %s, port: %s) entry from database...", host, port)); app.getExecutorLoader().removeExecutor(host, port); } catch (ExecutorManagerException ex) { logger.error(String.format("Exception when removing executor(host: %s, port: %s)", host, port), ex); } logger.warn("Shutting down executor..."); try { app.shutdownNow(); } catch (Exception e) { logger.error("Error while shutting down http server.", e); } } public void logTopMemoryConsumers() throws Exception, IOException { if (new File("/bin/bash").exists() && new File("/bin/ps").exists() && new File("/usr/bin/head").exists()) { logger.info("logging top memeory consumer"); java.lang.ProcessBuilder processBuilder = new java.lang.ProcessBuilder("/bin/bash", "-c", "/bin/ps aux --sort -rss | /usr/bin/head"); Process p = processBuilder.start(); p.waitFor(); InputStream is = p.getInputStream(); java.io.BufferedReader reader = new java.io.BufferedReader(new InputStreamReader(is)); String line = null; while ((line = reader.readLine()) != null) { logger.info(line); } is.close(); } } }); }
From source file:org.codehaus.modello.generator.jackson.JacksonVerifier.java
/** * TODO: Add a association thats not under the root element *//*from ww w. j av a 2 s .co m*/ public void verify() throws Exception { TimeZone.setDefault(TimeZone.getTimeZone("America/New_York")); verifyWriter(); }
From source file:org.xwiki.filter.test.integration.FilterTest.java
@Test public void execute() throws Throwable { TimeZone currentTimeZone = TimeZone.getDefault(); // Make sure to have a stable timezone during tests TimeZone.setDefault(TimeZone.getTimeZone("UTC")); Map<String, String> originalConfiguration = new HashMap<String, String>(); if (this.configuration.configuration != null) { ConfigurationSource configurationSource = getComponentManager().getInstance(ConfigurationSource.class); if (configurationSource instanceof MockConfigurationSource) { MockConfigurationSource mockConfigurationSource = (MockConfigurationSource) configurationSource; for (Map.Entry<String, String> entry : this.configuration.configuration.entrySet()) { originalConfiguration.put(entry.getKey(), mockConfigurationSource.<String>getProperty(entry.getKey())); mockConfigurationSource.setProperty(entry.getKey(), TestDataParser.interpret(entry.getValue())); }// ww w . j av a 2 s . co m } } try { runTestInternal(); } finally { // Restore current Timezone TimeZone.setDefault(currentTimeZone); // Revert Configuration that have been set if (this.configuration.configuration != null) { ConfigurationSource configurationSource = getComponentManager() .getInstance(ConfigurationSource.class); if (configurationSource instanceof MockConfigurationSource) { MockConfigurationSource mockConfigurationSource = (MockConfigurationSource) configurationSource; for (Map.Entry<String, String> entry : originalConfiguration.entrySet()) { if (entry.getValue() == null) { mockConfigurationSource.removeProperty(entry.getKey()); } else { mockConfigurationSource.setProperty(entry.getKey(), entry.getValue()); } } } } } }
From source file:ca.oson.json.gson.functional.DefaultTypeAdaptersTest.java
@Override protected void setUp() { super.setUp(); this.oldTimeZone = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles")); Locale.setDefault(Locale.US); gson = new Gson(); }
From source file:org.metawidget.integrationtest.swing.allwidgets.SwingAllWidgetsTest.java
public void testAllWidgets() throws Exception { TimeZone.setDefault(TimeZone.getTimeZone("GMT")); // BeanUtilsBinding ConvertUtils.register(//from ww w . j a v a 2s . c o m new org.metawidget.integrationtest.swing.allwidgets.converter.beanutils.DateConverter(DATE_FORMAT), Date.class); ConvertUtils.register( new org.metawidget.integrationtest.swing.allwidgets.converter.beanutils.NestedWidgetsConverter(), NestedWidgets.class); runTest(new BeanUtilsBindingProcessor()); }
From source file:ca.oson.json.gson.functional.DefaultTypeAdaptersTest.java
@Override protected void tearDown() { TimeZone.setDefault(oldTimeZone); super.tearDown(); }
From source file:net.audumla.astronomy.algorithims.AstronomicalTest.java
@Test public void testDateConversion() throws Exception { TimeZone.setDefault(TimeZone.getTimeZone("Australia/Melbourne")); java.util.Date date = new java.util.Date(); 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); }