List of usage examples for java.util Calendar getTimeZone
public TimeZone getTimeZone()
From source file:org.programmatori.domotica.own.sdk.config.Config.java
/** * Let you set the user time/*from w ww. ja va 2 s . c o m*/ */ public void setUserTime(Calendar userTime) { Calendar now = GregorianCalendar.getInstance(); timeDiff = TimeUtility.timeDiff(userTime, now); timeZone = userTime.getTimeZone(); }
From source file:org.psystems.dicom.browser.server.stat.StatDailyLoadChartServlet.java
/** * Returns a sample dataset.//from ww w . j av a 2s .c o m * * @return The dataset. */ private CategoryDataset createDataset() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); Calendar calendarEnd = Calendar.getInstance(); int tzoffset = calendarEnd.getTimeZone().getOffset(calendarEnd.getTimeInMillis()); long time = calendarEnd.getTimeInMillis(); time = time - (time % (60 * 60 * 24 * 1000)) - tzoffset; calendarEnd.setTimeInMillis(time); try { Connection connection = Util.getConnection("main", getServletContext()); Calendar calendarBegin = (Calendar) calendarEnd.clone(); calendarBegin.add(Calendar.DAY_OF_MONTH, -7); getMetrics(connection, "??? (DCM-)", "ALL_DCM_SIZE", calendarBegin.getTimeInMillis(), calendarEnd.getTimeInMillis(), dataset); getMetrics(connection, "? (JPG-)", "ALL_IMAGE_SIZE", calendarBegin.getTimeInMillis(), calendarEnd.getTimeInMillis(), dataset); } catch (SQLException e) { logger.error(e); e.printStackTrace(); } return dataset; }
From source file:org.fourthline.cling.osgi.test.integration.BaseIntegration.java
public boolean validate(String name, String type, Object value, Object desired) { boolean matches; System.out.printf("=========================================\n"); System.out.printf("data type: %s\n", type); System.out.printf(" value: %s (%s)\n", valueToString(value), value.getClass().getName()); System.out.printf(" desired: %s (%s)\n", valueToString(desired), desired.getClass().getName()); if (value instanceof UnsignedVariableInteger) { value = Integer.valueOf(((UnsignedVariableInteger) value).getValue().intValue()); } else if (value instanceof Calendar) { if (type.equals("time") || type.equals("time.tz")) { Calendar calendar = (Calendar) value; Date date = calendar.getTime(); long time = date.getTime() + calendar.getTimeZone().getOffset(date.getTime()); value = Long.valueOf(time); } else {//from w ww . j av a2 s. c o m value = ((Calendar) value).getTime(); } } else if (value instanceof Byte[]) { if (type.equals("bin.base64")) { value = Base64.decodeBase64(toBytes((Byte[]) value)); } else { value = toBytes((Byte[]) value); } } if (value instanceof byte[]) { matches = DataUtil.compareBytes((byte[]) value, (byte[]) desired); } else { matches = value.equals(desired); if (!matches) { matches = value.toString().equals(desired.toString()); } } System.out.printf(" matches: %s\n", matches ? "TRUE" : "FALSE"); return matches; }
From source file:com.mirth.connect.client.ui.StatusBar.java
public void setServerTime(Calendar serverTime) { timeOffset = serverTime.getTimeInMillis() - Calendar.getInstance().getTimeInMillis(); serverTimeZone = serverTime.getTimeZone().getID(); localTimeZone = Calendar.getInstance().getTimeZone().getID(); new Thread() { @Override/*from ww w. j a v a2s. c o m*/ public void run() { while (!Thread.currentThread().isInterrupted()) { try { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { timezoneLabel.setText(convertLocalToServerTime() + " " + timezoneText); } }); Thread.sleep(30000); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } catch (InvocationTargetException e) { } } } }.start(); }
From source file:org.psystems.dicom.browser.server.stat.StatClientRequestsChartServlet2.java
/** * Returns a sample dataset./*from w ww .j a va 2 s . c om*/ * * @return The dataset. */ private CategoryDataset createDataset() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); Calendar calendarEnd = Calendar.getInstance(); int tzoffset = calendarEnd.getTimeZone().getOffset(calendarEnd.getTimeInMillis()); long timeEnd = calendarEnd.getTimeInMillis(); timeEnd = timeEnd - (timeEnd % (60 * 60 * 24 * 1000)) - tzoffset; calendarEnd.setTimeInMillis(timeEnd); try { Connection connection = Util.getConnection("main", getServletContext()); Calendar calendarBegin = (Calendar) calendarEnd.clone(); calendarBegin.add(Calendar.DAY_OF_MONTH, -7); getMetrics(connection, "", "CLIENT_CONNECTIONS", calendarBegin, calendarEnd, dataset); getMetrics(connection, "", "CLIENT_CONNECTIONS", calendarBegin, calendarEnd, dataset); } catch (SQLException e) { logger.error(e); e.printStackTrace(); } // result.addValue(20.3, "product 1 (US)", "01.01.2010"); // result.addValue(27.2, "product 1 (US)", "02.01.2010"); // result.addValue(19.7, "product 1 (US)", "03.01.2010"); // result.addValue(19.7, "product 1 (US)", "04.01.2010"); // result.addValue(19.7, "product 1 (US)", "05.01.2010"); // result.addValue(19.7, "product 1 (US)", "06.01.2010"); // result.addValue(19.7, "product 1 (US)", "07.01.2010"); // // result.addValue(19.4, "product 1 (Europe)", "01.01.2010"); // result.addValue(10.9, "product 1 (Europe)", "02.01.2010"); // result.addValue(18.4, "product 1 (Europe)", "03.01.2010"); // result.addValue(19.7, "product 1 (Europe)", "04.01.2010"); // result.addValue(19.7, "product 1 (Europe)", "05.01.2010"); // result.addValue(19.7, "product 1 (Europe)", "06.01.2010"); // result.addValue(19.7, "product 1 (Europe)", "07.01.2010"); return dataset; }
From source file:org.psystems.dicom.browser.server.stat.StatDailyLoadChartServlet2.java
/** * Returns a sample dataset./* w ww . ja va 2 s. co m*/ * * @return The dataset. */ private CategoryDataset createDataset() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); Calendar calendarEnd = Calendar.getInstance(); int tzoffset = calendarEnd.getTimeZone().getOffset(calendarEnd.getTimeInMillis()); long timeEnd = calendarEnd.getTimeInMillis(); timeEnd = timeEnd - (timeEnd % (60 * 60 * 24 * 1000)) - tzoffset; calendarEnd.setTimeInMillis(timeEnd); try { Connection connection = Util.getConnection("main", getServletContext()); Calendar calendarBegin = (Calendar) calendarEnd.clone(); calendarBegin.add(Calendar.DAY_OF_MONTH, -7); getMetrics(connection, "??? (DCM-)", "ALL_DCM_SIZE", calendarBegin, calendarEnd, dataset); getMetrics(connection, "? (JPG-)", "ALL_IMAGE_SIZE", calendarBegin, calendarEnd, dataset); } catch (SQLException e) { logger.error(e); e.printStackTrace(); } // result.addValue(20.3, "product 1 (US)", "01.01.2010"); // result.addValue(27.2, "product 1 (US)", "02.01.2010"); // result.addValue(19.7, "product 1 (US)", "03.01.2010"); // result.addValue(19.7, "product 1 (US)", "04.01.2010"); // result.addValue(19.7, "product 1 (US)", "05.01.2010"); // result.addValue(19.7, "product 1 (US)", "06.01.2010"); // result.addValue(19.7, "product 1 (US)", "07.01.2010"); // // result.addValue(19.4, "product 1 (Europe)", "01.01.2010"); // result.addValue(10.9, "product 1 (Europe)", "02.01.2010"); // result.addValue(18.4, "product 1 (Europe)", "03.01.2010"); // result.addValue(19.7, "product 1 (Europe)", "04.01.2010"); // result.addValue(19.7, "product 1 (Europe)", "05.01.2010"); // result.addValue(19.7, "product 1 (Europe)", "06.01.2010"); // result.addValue(19.7, "product 1 (Europe)", "07.01.2010"); return dataset; }
From source file:org.fourthline.cling.osgi.test.integration.InitialIntegrationTest.java
private boolean validate(String name, String type, Object value, Object desired) { boolean matches; System.out.printf("=========================================\n"); System.out.printf("data type: %s\n", type); System.out.printf(" value: %s (%s)\n", valueToString(value), value.getClass().getName()); System.out.printf(" desired: %s (%s)\n", valueToString(desired), desired.getClass().getName()); if (value instanceof UnsignedVariableInteger) { value = Integer.valueOf(((UnsignedVariableInteger) value).getValue().intValue()); } else if (value instanceof Calendar) { if (type.equals("time") || type.equals("time.tz")) { Calendar calendar = (Calendar) value; Date date = calendar.getTime(); long time = date.getTime() + calendar.getTimeZone().getOffset(date.getTime()); value = Long.valueOf(time); } else {/*www .j a v a 2 s .c o m*/ value = ((Calendar) value).getTime(); } } if (value instanceof byte[]) { matches = DataUtil.compareBytes((byte[]) value, (byte[]) desired); } else { matches = value.equals(desired); if (!matches) { matches = value.toString().equals(desired.toString()); } } System.out.printf(" matches: %s\n", matches ? "TRUE" : "FALSE"); return matches; }
From source file:calendarexportplugin.exporter.GoogleExporter.java
private CalendarEventEntry findEntryForProgram(GoogleService myService, URL postUrl, String title, Program program) throws IOException, ServiceException { Calendar c = CalendarToolbox.getStartAsCalendar(program); DateTime startTime = new DateTime(c.getTime(), c.getTimeZone()); Query myQuery = new Query(postUrl); myQuery.setFullTextQuery(title);/*from w w w.j ava 2s. c o m*/ CalendarEventFeed myResultsFeed = myService.query(myQuery, CalendarEventFeed.class); for (CalendarEventEntry entry : myResultsFeed.getEntries()) { if ((entry.getTimes().size() > 0) && (entry.getTimes().get(0).getStartTime().getValue() == startTime.getValue())) { return entry; } } return null; }
From source file:com.github.hipchat.api.Room.java
public List<HistoryMessage> getHistory(Date date) { HipChat hc = getOrigin();/* www . j a va 2 s. c o m*/ Calendar c = Calendar.getInstance(); String dateString = null; String tzString = null; if (date != null) { c.setTime(date); TimeZone tz = c.getTimeZone(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); dateString = sdf.format(date); tzString = tz.getDisplayName(tz.inDaylightTime(date), TimeZone.SHORT); } else { Date tDate = new Date(); c.setTime(tDate); TimeZone tz = c.getTimeZone(); dateString = "recent"; tzString = tz.getDisplayName(tz.inDaylightTime(tDate), TimeZone.SHORT); } String query = String.format(HipChatConstants.ROOMS_HISTORY_QUERY_FORMAT, getId(), dateString, tzString, HipChatConstants.JSON_FORMAT, hc.getAuthToken()); OutputStream output = null; InputStream input = null; HttpURLConnection connection = null; List<HistoryMessage> messages = null; try { URL requestUrl = new URL(HipChatConstants.API_BASE + HipChatConstants.ROOMS_HISTORY + query); connection = (HttpURLConnection) requestUrl.openConnection(); connection.setDoInput(true); input = connection.getInputStream(); messages = MessageParser.parseRoomHistory(this, input); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { IOUtils.closeQuietly(output); connection.disconnect(); } return messages; }
From source file:org.openmrs.module.emrmonitor.metric.JavaRuntimeMetricProducer.java
/** * @return a list of produced metrics/*from w ww . j a v a 2 s . c om*/ */ @Override public Map<String, String> produceMetrics() { Map<String, String> metrics = new LinkedHashMap<String, String>(); // Memory Runtime runtime = Runtime.getRuntime(); metrics.put("memory.total", FormatUtil.formatBytes(runtime.totalMemory())); metrics.put("memory.total.bytes", Long.toString(runtime.totalMemory())); metrics.put("memory.free", FormatUtil.formatBytes(runtime.freeMemory())); metrics.put("memory.free.bytes", Long.toString(runtime.freeMemory())); metrics.put("memory.maximum", FormatUtil.formatBytes(runtime.maxMemory())); metrics.put("memory.maximum.bytes", Long.toString(runtime.maxMemory())); // Date/time Calendar cal = Calendar.getInstance(); metrics.put("datetime.display", DateFormat.getDateTimeInstance().format(cal.getTime())); metrics.put("datetime.date", DateFormatUtils.ISO_DATE_FORMAT.format(cal)); metrics.put("datetime.time", DateFormatUtils.ISO_TIME_NO_T_FORMAT.format(cal)); metrics.put("datetime.timezone", cal.getTimeZone().getDisplayName()); // Java Properties sp = System.getProperties(); metrics.put("version", sp.getProperty("java.version")); metrics.put("vendor", sp.getProperty("java.vendor")); metrics.put("jvmVersion", sp.getProperty("java.vm.version")); metrics.put("jvmVendor", sp.getProperty("java.vm.vendor")); metrics.put("runtimeName", sp.getProperty("java.runtime.name")); metrics.put("runtimeVersion", sp.getProperty("java.runtime.version")); metrics.put("user.name", sp.getProperty("user.name")); metrics.put("user.language", sp.getProperty("user.language")); metrics.put("user.timezone", sp.getProperty("user.timezone")); metrics.put("user.directory", sp.getProperty("user.dir")); metrics.put("encoding", sp.getProperty("sun.jnu.encoding")); metrics.put("tempDirectory", sp.getProperty("java.io.tmpdir")); return metrics; }