List of usage examples for java.util TimeZone getDefault
public static TimeZone getDefault()
From source file:com.clustercontrol.HinemosManagerMain.java
/** * Hinemos Manager?main<br/>//from w w w. j a v a2 s . c om * @param args * @throws Exception */ public static void main(String args[]) { try { try { if (System.getProperty("systime.iso") != null) { String oldVmName = System.getProperty("java.vm.name"); //System?mock?????HotSpot?????????? System.setProperty("java.vm.name", "HotSpot 64-Bit Server VM"); Class.forName("com.clustercontrol.util.SystemTimeShifter"); System.setProperty("java.vm.name", oldVmName); } } catch (Exception e) { log.error(e); } catch (Error e) { log.error(e); } long bootTime = System.currentTimeMillis(); log.info("Hinemos Manager is starting." + " (startupMode=" + _startupMode + ", clustered=" + _isClustered + ", locale=" + Locale.getDefault() + ")"); // Hinemos(??????)??????? // (???????????????????????) long offset = HinemosPropertyUtil.getHinemosPropertyNum("common.time.offset", Long.valueOf(0)); HinemosTime.setTimeOffsetMillis(offset); // Hinemos?(UTC??)??/(??) int timeZoneOffset = HinemosPropertyUtil .getHinemosPropertyNum("common.timezone", Long.valueOf(TimeZone.getDefault().getRawOffset())) .intValue(); HinemosTime.setTimeZoneOffset(timeZoneOffset); // ???HinemosPlugin??(create)? HinemosPluginService.getInstance().create(); // ???HinemosPlugin?(activate)? HinemosPluginService.getInstance().activate(); // Hinemos Manger???? Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { log.info("shutdown hook called."); synchronized (shutdownLock) { // Hinemos Manager??? String[] msgArgsShutdown = { _hostname }; AplLogger.put(PriorityConstant.TYPE_INFO, HinemosModuleConstant.HINEMOS_MANAGER_MONITOR, MessageConstant.MESSAGE_SYS_002_MNG, msgArgsShutdown); // ???HinemosPlugin??(deactivate)? HinemosPluginService.getInstance().deactivate(); // ???HinemosPlugin?(destroy)? HinemosPluginService.getInstance().destroy(); log.info("Hinemos Manager is stopped."); shutdown = true; shutdownLock.notify(); } } }); // ?? long startupTime = System.currentTimeMillis(); long initializeSec = (startupTime - bootTime) / 1000; long initializeMSec = (startupTime - bootTime) % 1000; log.info("Hinemos Manager Started in " + initializeSec + "s:" + initializeMSec + "ms"); // Hinemos Manager?? String[] msgArgsStart = { _hostname }; AplLogger.put(PriorityConstant.TYPE_INFO, HinemosModuleConstant.HINEMOS_MANAGER_MONITOR, MessageConstant.MESSAGE_SYS_001_MNG, msgArgsStart); // Hinemos Manager??????? synchronized (shutdownLock) { while (!shutdown) { try { shutdownLock.wait(); } catch (InterruptedException e) { log.warn("shutdown lock interrupted.", e); try { Thread.sleep(1000); } catch (InterruptedException sleepE) { } ; } } } System.exit(0); } catch (Throwable e) { log.error("unknown error occured.", e); } }
From source file:Main.java
public static int getTimeZone() { return TimeZone.getDefault().getRawOffset() / (1000 * 3600); }
From source file:Main.java
public static long getLocalDateFromUTC(long utcDate) { //// TimeZone tz = TimeZone.getDefault(); long gmtOffser = tz.getOffset(utcDate); return utcDate - gmtOffser; }
From source file:Main.java
public static String getTimeZone() { return TimeZone.getDefault().getDisplayName(false, 0); }
From source file:Main.java
public static String getTimeZoneOffset() { TimeZone timezone = TimeZone.getDefault(); int i = timezone.getRawOffset() / 1000; int j;//from ww w . j a v a 2 s . c o m double d; Object aobj[]; if (timezone.useDaylightTime() && timezone.inDaylightTime(new java.sql.Date(System.currentTimeMillis()))) j = 1; else j = 0; d = (double) i / 3600D + (double) j; aobj = new Object[1]; aobj[0] = Double.valueOf(d); return String.format("%.2f", aobj); }
From source file:Main.java
/** * Get the timezone//from w w w . j a va 2 s. co m * * @return */ public static String getTimeZone() { int time_zone = TimeZone.getDefault().getRawOffset() / 1000 / 3600; if (time_zone > 0) return "+" + time_zone; else return time_zone + ""; }
From source file:Main.java
public static Long GetUTCTime() { Calendar cal = Calendar.getInstance(TimeZone.getDefault(), Locale.getDefault()); int zoneOffset = cal.get(Calendar.ZONE_OFFSET); int dstOffset = cal.get(Calendar.DST_OFFSET); cal.add(java.util.Calendar.MILLISECOND, -(zoneOffset + dstOffset)); return cal.getTimeInMillis(); }
From source file:Main.java
public static boolean isInDaylightSavings() { return Boolean.valueOf(TimeZone.getDefault().inDaylightTime(new Date())); }
From source file:Main.java
public static boolean isInEasternEightZones() { boolean defaultVaule = true; if (TimeZone.getDefault() == TimeZone.getTimeZone("GMT+08")) defaultVaule = true;/*from www .j a v a 2 s. c o m*/ else defaultVaule = false; return defaultVaule; }
From source file:Main.java
private static int getDiffTimeZoneRawOffset() { return TimeZone.getDefault().getRawOffset() - TimeZone.getTimeZone(GMT).getRawOffset(); }