List of usage examples for java.util TimeZone setDefault
public static void setDefault(TimeZone zone)
From source file:fr.gael.dhus.DHuS.java
/** Starts the DHuS (starts Tomcat, creates the Spring application context. */ public static void start() { // Transfer System.err in logger System.setErr(new PrintStream(new LoggingOutputStream(LOGGER), true)); String version = DHuS.class.getPackage().getImplementationVersion(); // Force ehcache not to call home System.setProperty("net.sf.ehcache.skipUpdateCheck", "true"); System.setProperty("org.terracotta.quartz.skipUpdateCheck", "true"); System.setProperty("user.timezone", "UTC"); TimeZone.setDefault(TimeZone.getTimeZone("UTC")); System.setProperty("fr.gael.dhus.version", version == null ? "dev" : version); if (!SystemService.restore()) { LOGGER.error("Cannot run system restoration."); LOGGER.error("Check the restoration file \"" + SystemService.RESTORATION_PROPERTIES + "\" from the current directory."); System.exit(1);//w w w . ja v a2 s.c o m } Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { @Override public void run() { if ((server != null) && server.isRunning()) { try { server.stop(); } catch (TomcatException e) { e.printStackTrace(); } } } })); // Always add JMSAppender //Logger rootLogger = LogManager.getRootLogger (); //org.apache.logging.log4j.core.Logger coreLogger = //(org.apache.logging.log4j.core.Logger)rootLogger; //JMSAppender jmsAppender = JMSAppender.createAppender (); //coreLogger.addAppender (jmsAppender); try { // Activates the resolver for Drb DrbFactoryResolver.setMetadataResolver(new DrbCortexMetadataResolver(DrbCortexModel.getDefaultModel())); } catch (IOException e) { LOGGER.error("Resolver cannot be handled."); //logger.error (new Message(MessageType.SYSTEM, //"Resolver cannot be handled.")); } LOGGER.info("Launching Data Hub Service..."); //logger.info (new Message(MessageType.SYSTEM, //"Loading Data Hub Service...")); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "classpath:fr/gael/dhus/spring/dhus-core-context.xml"); context.registerShutdownHook(); // Registers ContextClosedEvent listeners to properly save states before // the Spring context is destroyed. ApplicationListener sync_sv = context.getBean(ISynchronizerService.class); context.addApplicationListener(sync_sv); // Initialize Database Incoming folder IncomingManager incoming_manager = (IncomingManager) context.getBean("incomingManager"); incoming_manager.initIncoming(); // Initialize DHuS loggers //jmsAppender.cleanWaitingLogs (); //logger.info (new Message(MessageType.SYSTEM, "DHuS Started")); try { //ftp = xml.getBean (FtpServer.class); //ftp.start (); server = ApplicationContextProvider.getBean(TomcatServer.class); server.init(); LOGGER.info("Starting server " + server.getClass() + "..."); //logger.info (new Message(MessageType.SYSTEM, "Starting server...")); server.start(); //logger.info (new Message(MessageType.SYSTEM, "Server started.")); LOGGER.info("Server started."); // Initialises SolrDAO SolrDao solr_dao = (SolrDao) context.getBean("solrDao"); solr_dao.initServerStarted(); Map<String, WebApplication> webapps = context.getBeansOfType(WebApplication.class); for (String beanName : webapps.keySet()) { server.install(webapps.get(beanName)); } fr.gael.dhus.server.http.web.WebApplication.installAll(server); WebServlet.installAll(server); WebPostProcess.launchAll(); LOGGER.info("Server is ready..."); started = true; //InitializableComponent.initializeAll (); //logger.info (new Message(MessageType.SYSTEM, "Server is ready...")); server.await(); } catch (Exception e) { LOGGER.error("Cannot start system.", e); //logger.error (new Message(MessageType.SYSTEM, "Cannot start DHuS."), e); //ftp.stop (); System.exit(1); } }
From source file:net.peterkuterna.android.apps.devoxxsched.util.UIUtils.java
/** * Format and return the given {@link Blocks} and {@link Rooms} values using * {@link #CONFERENCE_TIME_ZONE}./*from w ww .j av a2 s. co m*/ */ public static String formatSessionSubtitle(long blockStart, long blockEnd, String roomName, Context context) { TimeZone.setDefault(CONFERENCE_TIME_ZONE); final CharSequence dayString = DateUtils.formatDateRange(context, blockStart, blockEnd, DAY_FLAGS); final CharSequence timeString = DateUtils.formatDateRange(context, blockStart, blockEnd, TIME_FLAGS); return context.getString(R.string.session_subtitle, dayString, timeString, roomName); }
From source file:com.modelmetrics.cloudconverter.importxls.services.FileServiceImpl.java
/** * Parses an XLS file into a WrapperBean * //www .j av a 2 s . c o m * @param file * @return WrapperBean * @throws ParseException */ @SuppressWarnings("unchecked") public List<ExcelWorksheetWrapperBean> parseXLS(File file) throws ParseException { // keeps date fields real. TimeZone.setDefault(TimeZone.getTimeZone("-0")); List<ExcelWorksheetWrapperBean> wrapperBeans = new ArrayList<ExcelWorksheetWrapperBean>(); try { Workbook workbook; workbook = Workbook.getWorkbook(file); Sheet[] sheets = workbook.getSheets(); for (Sheet sheet : sheets) { ExcelWorksheetWrapperBean bean = new ExcelWorksheetWrapperBean(); bean.setSheetName(StringUtils.applyConstraints(sheet.getName())); int totalRows = sheet.getRows(); for (int i = 0; i < totalRows; i++) { Cell[] cells = sheet.getRow(i); List<Object> list = new ArrayList<Object>(); for (int j = 0; j < cells.length; j++) { Cell c = cells[j]; // log.debug("cell format is: (i,j) (" + i + ", " + j + // "): // " + c.getCellFormat().getFormat().getFormatString()); String value = c.getContents(); if (i == 0) { // parse column names bean.getNames().add(StringUtils.applyConstraints(value)); bean.getLabels().add(value); } if (i == 1) { // parse data types CellType type = c.getType(); if (type.equals(CellType.DATE) || type.equals(CellType.DATE_FORMULA)) { if (value.contains(":")) { bean.getTypes().add(Constants.DATETIME); } else { bean.getTypes().add(Constants.DATE); } } else if (type.equals(CellType.BOOLEAN) || type.equals(CellType.BOOLEAN_FORMULA)) { bean.getTypes().add(Constants.CHECKBOX); } else if (type.equals(CellType.LABEL) || type.equals(CellType.STRING_FORMULA)) { if (GenericValidator.isEmail(value)) { bean.getTypes().add(Constants.EMAIL); } else if (StringUtils.isPhoneNumber(value)) { bean.getTypes().add(Constants.PHONE_NUMBER); } else if (StringUtils.isURL(value)) { bean.getTypes().add(Constants.URL); } else { bean.getTypes().add(Constants.TEXT); } } else if (type.equals(CellType.NUMBER) || type.equals(CellType.NUMBER_FORMULA)) { log.debug("Number: " + value + " : format : " + c.getCellFormat().getFormat().getFormatString()); if (value.contains("%")) { bean.getTypes().add(Constants.PERCENTAGE); } else if (value.contains("$")) { bean.getTypes().add(Constants.CURRENCY); } else if (value.contains(",") || value.contains(".")) { bean.getTypes().add(Constants.DOUBLE); } else { bean.getTypes().add(Constants.INT); } } else { // default. bean.getTypes().add(Constants.TEXT); } } if (i >= 1) { // parse data values CellType type = c.getType(); if (type.equals(CellType.BOOLEAN) || type.equals(CellType.BOOLEAN_FORMULA)) { list.add(((BooleanCell) c).getValue()); } else if (type.equals(CellType.DATE) || type.equals(CellType.DATE_FORMULA)) { Date aux = ((DateCell) c).getDate(); list.add(aux); // } } else if (type.equals(CellType.LABEL) || type.equals(CellType.STRING_FORMULA)) { list.add(value); } else if (type.equals(CellType.EMPTY)) { list.add(null); } else if (type.equals(CellType.NUMBER) || type.equals(CellType.NUMBER_FORMULA)) { if (value.contains("%")) { // otherwise "percentages" show up in SFDC // as // 0.78 when it should be 78%. list.add(((NumberCell) c).getValue() * 100); } else { list.add(((NumberCell) c).getValue()); } } if (i == 1) { bean.getExamples().add(value); } } } if (i >= 1) { /* * RSC 2009-06-02 Check to be sure there is data in a list */ boolean notEmpty = false; for (Object o : list) { if (o != null && o.toString().trim().length() != 0) { notEmpty = true; break; } } if (!notEmpty) { throw new RuntimeException( "Found an empty row. Your spreadsheet should not contain an empty row. Check sheet " + sheet.getName() + ", row " + (i + 1) + "."); } bean.getData().add(list); bean.setOverride(Boolean.FALSE); } } wrapperBeans.add(bean); } } catch (BiffException e) { throw new ParseException("Could not read file"); } catch (IOException e) { throw new ParseException("Input/Output error"); } catch (IndexOutOfBoundsException e) { throw new ParseException("Columns and data do not match"); } catch (NullPointerException e) { throw new ParseException("A reference in the file has a null value"); } return wrapperBeans; }
From source file:ca.uhn.hl7v2.model.primitive.CommonTSTest.java
@AfterClass public static void tearDownBeforeClass() { TimeZone.setDefault(tz); }
From source file:org.apache.apex.malhar.sql.FileEndpointTest.java
@After public void tearDown() throws Exception { TimeZone.setDefault(defaultTZ); }
From source file:org.geoserver.wms.dimension.RasterTimeDimensionDefaultValueTest.java
@Override protected void onSetUp(SystemTestData testData) throws Exception { super.onSetUp(testData); TimeZone.setDefault(TimeZone.getTimeZone("UTC")); prepareFutureCoverageData(WATTEMP_FUTURE); }
From source file:com.modelmetrics.cloudconverter.importxls.services.ExcelFileParserServiceImpl.java
/** * Parses an XLS file into a WrapperBean * /*from ww w . ja v a 2s .c om*/ * @param file * @return WrapperBean * @throws ParseException */ @SuppressWarnings("unchecked") public List<ExcelWorksheetWrapperBean> parseXLS(File file) throws ParseException { //TODO DB -- validate that dates are working with TZ and SFDC properly. Use sample input v1 // keeps date fields real. TimeZone.setDefault(TimeZone.getTimeZone("-0")); List<ExcelWorksheetWrapperBean> wrapperBeans = new ArrayList<ExcelWorksheetWrapperBean>(); try { Workbook workbook; workbook = Workbook.getWorkbook(file); Sheet[] sheets = workbook.getSheets(); for (Sheet sheet : sheets) { ExcelWorksheetWrapperBean bean = new ExcelWorksheetWrapperBean(); bean.setSheetName(StringUtils.applyConstraints(sheet.getName())); int totalRows = sheet.getRows(); for (int i = 0; i < totalRows; i++) { Cell[] cells = sheet.getRow(i); List<Object> list = new ArrayList<Object>(); for (int j = 0; j < cells.length; j++) { Cell c = cells[j]; // log.debug("cell format is: (i,j) (" + i + ", " + j + // "): // " + c.getCellFormat().getFormat().getFormatString()); String value = c.getContents(); if (i == 0) { // parse column names bean.getNames().add(StringUtils.applyConstraints(value)); bean.getLabels().add(value); } if (i == 1) { // parse data types CellType type = c.getType(); if (type.equals(CellType.DATE) || type.equals(CellType.DATE_FORMULA)) { if (value.contains(":")) { bean.getTypes().add(Constants.DATETIME); } else { bean.getTypes().add(Constants.DATE); } } else if (type.equals(CellType.BOOLEAN) || type.equals(CellType.BOOLEAN_FORMULA)) { bean.getTypes().add(Constants.CHECKBOX); } else if (type.equals(CellType.LABEL) || type.equals(CellType.STRING_FORMULA)) { if (GenericValidator.isEmail(value)) { bean.getTypes().add(Constants.EMAIL); } else if (StringUtils.isPhoneNumber(value)) { bean.getTypes().add(Constants.PHONE_NUMBER); } else if (StringUtils.isURL(value)) { bean.getTypes().add(Constants.URL); } else { bean.getTypes().add(Constants.TEXT); } } else if (type.equals(CellType.NUMBER) || type.equals(CellType.NUMBER_FORMULA)) { log.debug("Number: " + value + " : format : " + c.getCellFormat().getFormat().getFormatString()); if (value.contains("%")) { bean.getTypes().add(Constants.PERCENTAGE); } else if (value.contains("$")) { bean.getTypes().add(Constants.CURRENCY); } else if (value.contains(",") || value.contains(".")) { bean.getTypes().add(Constants.DOUBLE); } else { bean.getTypes().add(Constants.INT); } } else { // default. bean.getTypes().add(Constants.TEXT); } } if (i >= 1) { // parse data values CellType type = c.getType(); if (type.equals(CellType.BOOLEAN) || type.equals(CellType.BOOLEAN_FORMULA)) { list.add(((BooleanCell) c).getValue()); } else if (type.equals(CellType.DATE) || type.equals(CellType.DATE_FORMULA)) { Date aux = ((DateCell) c).getDate(); list.add(aux); // } } else if (type.equals(CellType.LABEL) || type.equals(CellType.STRING_FORMULA)) { list.add(value); } else if (type.equals(CellType.EMPTY)) { list.add(null); } else if (type.equals(CellType.NUMBER) || type.equals(CellType.NUMBER_FORMULA)) { if (value.contains("%")) { // otherwise "percentages" show up in SFDC // as // 0.78 when it should be 78%. list.add(((NumberCell) c).getValue() * 100); } else { list.add(((NumberCell) c).getValue()); } } if (i == 1) { bean.getExamples().add(value); } } } //TODO DB make sure this is working for worksheets that have no row with DATA (Think Erin's email) if (i >= 1) { /* * RSC 2009-06-02 Check to be sure there is data in a list */ boolean notEmpty = false; for (Object o : list) { if (o != null && o.toString().trim().length() != 0) { notEmpty = true; break; } } if (!notEmpty) { throw new RuntimeException( "Found an empty row. Your spreadsheet should not contain an empty row. Check sheet " + sheet.getName() + ", row " + (i + 1) + "."); } bean.getData().add(list); bean.setOverride(Boolean.FALSE); } } wrapperBeans.add(bean); } } catch (BiffException e) { throw new ParseException("Could not read file"); } catch (IOException e) { throw new ParseException("Input/Output error"); } catch (IndexOutOfBoundsException e) { throw new ParseException("Columns and data do not match"); } catch (NullPointerException e) { throw new ParseException("A reference in the file has a null value"); } return wrapperBeans; }
From source file:hudson.plugins.timestamper.TimestampNoteTest.java
/** * @throws Exception/*from w ww .j a va 2 s. c o m*/ */ @Before public void setUp() throws Exception { systemDefaultTimeZone = TimeZone.getDefault(); // Set the time zone to get consistent results. TimeZone.setDefault(TimeZone.getTimeZone("GMT")); setSystemTimeFormat(FORMAT); }
From source file:tvbrowser.TVBrowser.java
/** * Entry point of the application//from w w w . ja va 2 s .c o m * @param args The arguments given in the command line. */ public static void main(String[] args) { // Read the command line parameters parseCommandline(args); try { Toolkit.getDefaultToolkit().setDynamicLayout( (Boolean) Toolkit.getDefaultToolkit().getDesktopProperty("awt.dynamicLayoutSupported")); } catch (Exception e) { e.printStackTrace(); } mLocalizer = util.ui.Localizer.getLocalizerFor(TVBrowser.class); // Check whether the TV-Browser was started in the right directory if (!new File("imgs").exists()) { String msg = "Please start TV-Browser in the TV-Browser directory!"; if (mLocalizer != null) { msg = mLocalizer.msg("error.2", "Please start TV-Browser in the TV-Browser directory!"); } JOptionPane.showMessageDialog(null, msg); System.exit(1); } if (mIsTransportable) { System.getProperties().remove("propertiesfile"); } // setup logging // Get the default Logger Logger mainLogger = Logger.getLogger(""); // Use a even simpler Formatter for console logging mainLogger.getHandlers()[0].setFormatter(createFormatter()); if (mIsTransportable) { File settingsDir = new File("settings"); try { File test = File.createTempFile("write", "test", settingsDir); test.delete(); } catch (IOException e) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e1) { //ignore } JTextArea area = new JTextArea(mLocalizer.msg("error.noWriteRightsText", "You are using the transportable version of TV-Browser but you have no writing rights in the settings directory:\n\n{0}'\n\nTV-Browser will be closed.", settingsDir.getAbsolutePath())); area.setFont(new JLabel().getFont()); area.setFont(area.getFont().deriveFont((float) 14).deriveFont(Font.BOLD)); area.setLineWrap(true); area.setWrapStyleWord(true); area.setPreferredSize(new Dimension(500, 100)); area.setEditable(false); area.setBorder(null); area.setOpaque(false); JOptionPane.showMessageDialog(null, area, mLocalizer.msg("error.noWriteRightsTitle", "No write rights in settings directory"), JOptionPane.ERROR_MESSAGE); System.exit(1); } } // Load the settings Settings.loadSettings(); Locale.setDefault(new Locale(Settings.propLanguage.getString(), Settings.propCountry.getString())); if (Settings.propFirstStartDate.getDate() == null) { Settings.propFirstStartDate.setDate(Date.getCurrentDate()); } if (!createLockFile()) { updateLookAndFeel(); showTVBrowserIsAlreadyRunningMessageBox(); } String logDirectory = Settings.propLogdirectory.getString(); if (logDirectory != null) { try { File logDir = new File(logDirectory); logDir.mkdirs(); mainLogger.addHandler( new FileLoggingHandler(logDir.getAbsolutePath() + "/tvbrowser.log", createFormatter())); } catch (IOException exc) { String msg = mLocalizer.msg("error.4", "Can't create log file."); ErrorHandler.handle(msg, exc); } } else { // if no logging is configured, show WARNING or worse for normal usage, show everything for unstable versions if (TVBrowser.isStable()) { mainLogger.setLevel(Level.WARNING); } } // log warning for OpenJDK users if (!isJavaImplementationSupported()) { mainLogger.warning(SUN_JAVA_WARNING); } //Update plugin on version change if (Settings.propTVBrowserVersion.getVersion() != null && VERSION.compareTo(Settings.propTVBrowserVersion.getVersion()) > 0) { updateLookAndFeel(); updatePluginsOnVersionChange(); } // Capture unhandled exceptions //System.setErr(new PrintStream(new MonitoringErrorStream())); String timezone = Settings.propTimezone.getString(); if (timezone != null) { TimeZone.setDefault(TimeZone.getTimeZone(timezone)); } mLog.info("Using timezone " + TimeZone.getDefault().getDisplayName()); // refresh the localizers because we know the language now Localizer.emptyLocalizerCache(); mLocalizer = Localizer.getLocalizerFor(TVBrowser.class); ProgramInfo.resetLocalizer(); ReminderPlugin.resetLocalizer(); Date.resetLocalizer(); ProgramFieldType.resetLocalizer(); // Set the proxy settings updateProxySettings(); // Set the String to use for indicating the user agent in http requests System.setProperty("http.agent", MAINWINDOW_TITLE); Version tmpVer = Settings.propTVBrowserVersion.getVersion(); final Version currentVersion = tmpVer != null ? new Version(tmpVer.getMajor(), tmpVer.getMinor(), Settings.propTVBrowserVersionIsStable.getBoolean()) : tmpVer; /*TODO Create an update service for installed TV data services that doesn't * work with TV-Browser 3.0 and updates for them are known. */ if (!isTransportable() && Launch.isOsWindowsNtBranch() && currentVersion != null && currentVersion.compareTo(new Version(3, 0, true)) < 0) { String tvDataDir = Settings.propTVDataDirectory.getString().replace("/", File.separator); if (!tvDataDir.startsWith(System.getenv("appdata"))) { StringBuilder oldDefaultTvDataDir = new StringBuilder(System.getProperty("user.home")) .append(File.separator).append("TV-Browser").append(File.separator).append("tvdata"); if (oldDefaultTvDataDir.toString().equals(tvDataDir)) { Settings.propTVDataDirectory.setString(Settings.propTVDataDirectory.getDefault()); } } } Settings.propTVBrowserVersion.setVersion(VERSION); Settings.propTVBrowserVersionIsStable.setBoolean(VERSION.isStable()); final Splash splash; if (mShowSplashScreen && Settings.propSplashShow.getBoolean()) { splash = new SplashScreen(Settings.propSplashImage.getString(), Settings.propSplashTextPosX.getInt(), Settings.propSplashTextPosY.getInt(), Settings.propSplashForegroundColor.getColor()); } else { splash = new DummySplash(); } splash.showSplash(); /* Initialize the MarkedProgramsList */ MarkedProgramsList.getInstance(); /*Maybe there are tvdataservices to install (.jar.inst files)*/ PluginLoader.getInstance().installPendingPlugins(); PluginLoader.getInstance().loadAllPlugins(); mLog.info("Loading TV listings service..."); splash.setMessage(mLocalizer.msg("splash.dataService", "Loading TV listings service...")); TvDataServiceProxyManager.getInstance().init(); ChannelList.createForTvBrowserStart(); ChannelList.initSubscribedChannels(); if (!lookAndFeelInitialized) { mLog.info("Loading Look&Feel..."); splash.setMessage(mLocalizer.msg("splash.laf", "Loading look and feel...")); updateLookAndFeel(); } mLog.info("Loading plugins..."); splash.setMessage(mLocalizer.msg("splash.plugins", "Loading plugins...")); try { PluginProxyManager.getInstance().init(); } catch (TvBrowserException exc) { ErrorHandler.handle(exc); } splash.setMessage(mLocalizer.msg("splash.tvData", "Checking TV database...")); mLog.info("Checking TV listings inventory..."); TvDataBase.getInstance().checkTvDataInventory(); mLog.info("Starting up..."); splash.setMessage(mLocalizer.msg("splash.ui", "Starting up...")); Toolkit.getDefaultToolkit().getSystemEventQueue().push(new TextComponentPopupEventQueue()); // Init the UI final boolean fStartMinimized = Settings.propMinimizeAfterStartup.getBoolean() || mMinimized; SwingUtilities.invokeLater(new Runnable() { public void run() { initUi(splash, fStartMinimized); new Thread("Start finished callbacks") { public void run() { setPriority(Thread.MIN_PRIORITY); mLog.info("Deleting expired TV listings..."); TvDataBase.getInstance().deleteExpiredFiles(1, false); // first reset "starting" flag of mainframe mainFrame.handleTvBrowserStartFinished(); // initialize program info for fast reaction to program table click ProgramInfo.getInstance().handleTvBrowserStartFinished(); // load reminders and favorites ReminderPlugin.getInstance().handleTvBrowserStartFinished(); FavoritesPlugin.getInstance().handleTvBrowserStartFinished(); // now handle all plugins and services GlobalPluginProgramFormatingManager.getInstance(); PluginProxyManager.getInstance().fireTvBrowserStartFinished(); TvDataServiceProxyManager.getInstance().fireTvBrowserStartFinished(); // finally submit plugin caused updates to database TvDataBase.getInstance().handleTvBrowserStartFinished(); startPeriodicSaveSettings(); } }.start(); SwingUtilities.invokeLater(new Runnable() { public void run() { ChannelList.completeChannelLoading(); initializeAutomaticDownload(); if (Launch.isOsWindowsNtBranch()) { try { RegistryKey desktopSettings = new RegistryKey(RootKey.HKEY_CURRENT_USER, "Control Panel\\Desktop"); RegistryValue autoEnd = desktopSettings.getValue("AutoEndTasks"); if (autoEnd.getData().equals("1")) { RegistryValue killWait = desktopSettings.getValue("WaitToKillAppTimeout"); int i = Integer.parseInt(killWait.getData().toString()); if (i < 5000) { JOptionPane pane = new JOptionPane(); String cancel = mLocalizer.msg("registryCancel", "Close TV-Browser"); String dontDoIt = mLocalizer.msg("registryJumpOver", "Not this time"); pane.setOptions(new String[] { Localizer.getLocalization(Localizer.I18N_OK), dontDoIt, cancel }); pane.setOptionType(JOptionPane.YES_NO_CANCEL_OPTION); pane.setMessageType(JOptionPane.WARNING_MESSAGE); pane.setMessage(mLocalizer.msg("registryWarning", "The fast shutdown of Windows is activated.\nThe timeout to wait for before Windows is closing an application is too short,\nto give TV-Browser enough time to save all settings.\n\nThe setting hasn't the default value. It was changed by a tool or by you.\nTV-Browser will now try to change the timeout.\n\nIf you don't want to change this timeout select 'Not this time' or 'Close TV-Browser'.")); pane.setInitialValue(mLocalizer.msg("registryCancel", "Close TV-Browser")); JDialog d = pane.createDialog(UiUtilities.getLastModalChildOf(mainFrame), UIManager.getString("OptionPane.messageDialogTitle")); d.setModal(true); UiUtilities.centerAndShow(d); if (pane.getValue() == null || pane.getValue().equals(cancel)) { mainFrame.quit(); } else if (!pane.getValue().equals(dontDoIt)) { try { killWait.setData("5000"); desktopSettings.setValue(killWait); JOptionPane.showMessageDialog( UiUtilities.getLastModalChildOf(mainFrame), mLocalizer.msg("registryChanged", "The timeout was changed successfully.\nPlease reboot Windows!")); } catch (Exception registySetting) { JOptionPane.showMessageDialog( UiUtilities.getLastModalChildOf(mainFrame), mLocalizer.msg("registryNotChanged", "<html>The Registry value couldn't be changed. Maybe you haven't the right to do it.<br>If it is so contact you Administrator and let him do it for you.<br><br><b><Attention:/b> The following description is for experts. If you change or delete the wrong value in the Registry you could destroy your Windows installation.<br><br>To get no warning on TV-Browser start the Registry value <b>WaitToKillAppTimeout</b> in the Registry path<br><b>HKEY_CURRENT_USER\\Control Panel\\Desktop</b> have to be at least <b>5000</b> or the value for <b>AutoEndTasks</b> in the same path have to be <b>0</b>.</html>"), Localizer.getLocalization(Localizer.I18N_ERROR), JOptionPane.ERROR_MESSAGE); } } } } } catch (Throwable registry) { } } if (currentVersion != null && currentVersion.compareTo(new Version(2, 71, false)) < 0) { if (Settings.propProgramPanelMarkedMinPriorityColor.getColor() .equals(Settings.propProgramPanelMarkedMinPriorityColor.getDefaultColor())) { Settings.propProgramPanelMarkedMinPriorityColor.setColor(new Color(255, 0, 0, 30)); } if (Settings.propProgramPanelMarkedMediumPriorityColor.getColor() .equals(Settings.propProgramPanelMarkedMediumPriorityColor.getDefaultColor())) { Settings.propProgramPanelMarkedMediumPriorityColor .setColor(new Color(140, 255, 0, 60)); } if (Settings.propProgramPanelMarkedHigherMediumPriorityColor.getColor().equals( Settings.propProgramPanelMarkedHigherMediumPriorityColor.getDefaultColor())) { Settings.propProgramPanelMarkedHigherMediumPriorityColor .setColor(new Color(255, 255, 0, 60)); } if (Settings.propProgramPanelMarkedMaxPriorityColor.getColor() .equals(Settings.propProgramPanelMarkedMaxPriorityColor.getDefaultColor())) { Settings.propProgramPanelMarkedMaxPriorityColor .setColor(new Color(255, 180, 0, 110)); } } // check if user should select picture settings if (currentVersion != null && currentVersion.compareTo(new Version(2, 22)) < 0) { TvBrowserPictureSettingsUpdateDialog.createAndShow(mainFrame); } else if (currentVersion != null && currentVersion.compareTo(new Version(2, 51, true)) < 0) { Settings.propAcceptedLicenseArrForServiceIds.setStringArray(new String[0]); } if (currentVersion != null && currentVersion.compareTo(new Version(2, 60, true)) < 0) { int startOfDay = Settings.propProgramTableStartOfDay.getInt(); int endOfDay = Settings.propProgramTableEndOfDay.getInt(); if (endOfDay - startOfDay < -1) { Settings.propProgramTableEndOfDay.setInt(startOfDay); JOptionPane.showMessageDialog(UiUtilities.getLastModalChildOf(mainFrame), mLocalizer.msg("timeInfoText", "The time range of the program table was corrected because the defined day was shorter than 24 hours.\n\nIf the program table should show less than 24h use a time filter for that. That time filter can be selected\nto be the default filter by selecting it in the filter settings and pressing on the button 'Default'."), mLocalizer.msg("timeInfoTitle", "Times corrected"), JOptionPane.INFORMATION_MESSAGE); Settings.handleChangedSettings(); } } MainFrame.getInstance().getProgramTableScrollPane().requestFocusInWindow(); } }); } }); // register the shutdown hook Runtime.getRuntime().addShutdownHook(new Thread("Shutdown hook") { public void run() { deleteLockFile(); MainFrame.getInstance().quit(false); } }); }
From source file:com.microsoft.exchange.DateHelpTest.java
@Test public void systemTimeZone() { List<String> availableIDs = Arrays.asList(TimeZone.getAvailableIDs()); assertFalse(CollectionUtils.isEmpty(availableIDs)); assertTrue(availableIDs.contains(TimeZones.UTC_ID)); assertTrue(availableIDs.contains("UTC")); TimeZone ical4jUTC = TimeZone.getTimeZone(TimeZones.UTC_ID); TimeZone sysUTC = TimeZone.getTimeZone("UTC"); assertEquals(ical4jUTC.getDSTSavings(), sysUTC.getDSTSavings()); assertEquals(ical4jUTC.getRawOffset(), sysUTC.getRawOffset()); assertTrue(ical4jUTC.hasSameRules(sysUTC)); TimeZone origDefaultTimeZone = TimeZone.getDefault(); assertNotNull(origDefaultTimeZone);/*w w w .j a v a2s.com*/ assertEquals(TimeZone.getDefault().getRawOffset(), origDefaultTimeZone.getRawOffset()); log.info("TimeZone.DisplayName=" + origDefaultTimeZone.getDisplayName()); log.info("TimeZone.ID=" + origDefaultTimeZone.getID()); log.info("TimeZone.DSTSavings=" + origDefaultTimeZone.getDSTSavings()); log.info("TimeZone.RawOffset=" + origDefaultTimeZone.getRawOffset()); log.info("TimeZone.useDaylightTime=" + origDefaultTimeZone.useDaylightTime()); TimeZone.setDefault(ical4jUTC); assertEquals(ical4jUTC, TimeZone.getDefault()); log.info(" -- Defualt Time Zone has been changed successfully! -- "); TimeZone newDefaultTimeZone = TimeZone.getDefault(); log.info("TimeZone.DisplayName=" + newDefaultTimeZone.getDisplayName()); log.info("TimeZone.ID=" + newDefaultTimeZone.getID()); log.info("TimeZone.DSTSavings=" + newDefaultTimeZone.getDSTSavings()); log.info("TimeZone.RawOffset=" + newDefaultTimeZone.getRawOffset()); log.info("TimeZone.useDaylightTime=" + newDefaultTimeZone.useDaylightTime()); }