List of usage examples for java.text SimpleDateFormat setTimeZone
public void setTimeZone(TimeZone zone)
From source file:de.forsthaus.webui.calendar.CalendarCreateEventCtrl.java
/** * Automatically called method from zk.//from www . j a v a2 s .co m * * @param event * @throws Exception */ public void onCreate$createEventWindow(Event event) { List dateTime = new LinkedList(); // Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance(org.zkoss.util.Locales.getCurrent()); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); for (int i = 0; i < 48; i++) { dateTime.add(sdf.format(calendar.getTime())); calendar.add(Calendar.MINUTE, 30); } ppbt.setModel(new ListModelList(dateTime)); ppet.setModel(new ListModelList(dateTime)); CalendarsEvent evt = getNewEvent(); int left = evt.getX(); int top = evt.getY(); if (top + 245 > evt.getDesktopHeight()) top = evt.getDesktopHeight() - 245; if (left + 410 > evt.getDesktopWidth()) left = evt.getDesktopWidth() - 410; createEventWindow.setLeft(left + "px"); createEventWindow.setTop(top + "px"); SimpleDateFormat create_sdf = new SimpleDateFormat("HH:mm"); create_sdf.setTimeZone(getCalendarCtrl().getCal().getDefaultTimeZone()); // Calendar calendar = // Calendar.getInstance(org.zkoss.util.Locales.getCurrent()); String[] times = create_sdf.format(evt.getBeginDate()).split(":"); int hours = Integer.parseInt(times[0]) * 2; int mins = Integer.parseInt(times[1]); int bdTimeSum = hours + mins; if (mins >= 30) hours++; ppbt.setSelectedIndex(hours); times = create_sdf.format(evt.getEndDate()).split(":"); hours = Integer.parseInt(times[0]) * 2; mins = Integer.parseInt(times[1]); int edTimeSum = hours + mins; if (mins >= 30) hours++; ppet.setSelectedIndex(hours); boolean isAllday = (bdTimeSum + edTimeSum) == 0; ppbegin.setTimeZone(getCalendarCtrl().getCal().getDefaultTimeZone()); ppbegin.setValue(evt.getBeginDate()); ppend.setTimeZone(getCalendarCtrl().getCal().getDefaultTimeZone()); ppend.setValue(evt.getEndDate()); ppallDay.setChecked(isAllday); pplocked.setChecked(false); ppbt.setVisible(!isAllday); ppet.setVisible(!isAllday); createEventWindow.setVisible(true); createEventWindow.setAttribute("calendars", getCalendarCtrl().getCal()); createEventWindow.setAttribute("calevent", evt); evt.stopClearGhost(); }
From source file:com.clustercontrol.collect.util.CollectGraphUtil.java
/** * DB??????<br />/*from w ww. j av a 2 s . com*/ * ????????????????<br> * ?????????????<br> * DB?????facilityId?????CollectId?????<br> * * @param managerName * @param monitorId * @param displayName * @param itemName * @param fromTime * @param toTime * @return key:collectId, value:CollectData? * @throws InvalidRole_Exception * @throws HinemosUnknown_Exception * @throws InvalidUserPass_Exception */ private static Map<Integer, List<CollectData>> getGraphDetailDataMap(String managerName, String monitorId, String displayName, String itemName, Long fromTime, Long toTime) throws InvalidUserPass_Exception, HinemosUnknown_Exception, InvalidRole_Exception { long start = System.currentTimeMillis(); SimpleDateFormat DF = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSS"); DF.setTimeZone(TimezoneUtil.getTimeZone()); m_log.info("getGraphDetailDataMap() managerName:" + managerName + ", monitorId:" + monitorId + ", displayName:" + displayName + ", itemName:" + itemName + ", fromTime:" + DF.format(new Date(fromTime)) + ", toTime:" + DF.format(new Date(toTime)) + ", summaryType:" + getInstance().m_summaryType); Map<Integer, List<CollectData>> map = new HashMap<>(); List<Integer> collectIdList = null; if (getInstance().m_managerMonitorCollectIdMap.get(managerName) == null) { m_log.warn("??manager???? managerName" + managerName); } else { collectIdList = getInstance().m_managerMonitorCollectIdMap.get(managerName) .get(itemName + displayName + monitorId); } if (collectIdList == null || collectIdList.isEmpty()) { m_log.info("collectIdList????DB??????? managerName:" + managerName); return map; } // ?????????????? // ????????????????javascript??? if (getInstance().m_summaryType == SummaryTypeConstant.TYPE_RAW) { // nop } else if (getInstance().m_summaryType == SummaryTypeConstant.TYPE_AVG_HOUR || getInstance().m_summaryType == SummaryTypeConstant.TYPE_MIN_HOUR || getInstance().m_summaryType == SummaryTypeConstant.TYPE_MAX_HOUR) { fromTime -= MILLISECOND_HOUR; toTime += MILLISECOND_HOUR; } else if (getInstance().m_summaryType == SummaryTypeConstant.TYPE_AVG_DAY || getInstance().m_summaryType == SummaryTypeConstant.TYPE_MIN_DAY || getInstance().m_summaryType == SummaryTypeConstant.TYPE_MAX_DAY) { fromTime -= MILLISECOND_DAY; toTime += MILLISECOND_DAY; } else if (getInstance().m_summaryType == SummaryTypeConstant.TYPE_AVG_MONTH || getInstance().m_summaryType == SummaryTypeConstant.TYPE_MIN_MONTH || getInstance().m_summaryType == SummaryTypeConstant.TYPE_MAX_MONTH) { fromTime -= MILLISECOND_MONTH; toTime += MILLISECOND_MONTH; } m_log.debug("getGraphDetailDataMap() REAL fromTime:" + DF.format(new Date(fromTime)) + ", toTime:" + DF.format(new Date(toTime))); CollectEndpointWrapper wrapper = CollectEndpointWrapper.getWrapper(managerName); HashMapInfo mapInfo = wrapper.getCollectData(collectIdList, getInstance().m_summaryType, fromTime, toTime); Map3 map3 = mapInfo.getMap3(); int count = 0; for (com.clustercontrol.ws.collect.HashMapInfo.Map3.Entry entry3 : map3.getEntry()) { // key?collectId?value?????(CollectData)? map.put(entry3.getKey(), entry3.getValue().getList()); count += entry3.getValue().getList().size(); } m_log.debug("getGraphDetailDataMap : monitorId=" + monitorId + ", size=" + count + ", collectIdList.size:" + collectIdList.size()); m_log.debug("getGraphDetailDataMap() DB time=" + (System.currentTimeMillis() - start) + "ms"); return map; }
From source file:com.krawler.spring.calendar.calendarmodule.crmCalendarController.java
public ModelAndView getAllEvents(HttpServletRequest request, HttpServletResponse response) throws ServletException { List<CalendarEvent> result = null; List<CalendarEvent> modEvents = null; TimeZone tz;/* www .ja v a 2 s . c o m*/ try { tz = TimeZone.getTimeZone("GMT" + sessionHandlerImpl.getTimeZoneDifference(request)); } catch (SessionExpiredException e1) { tz = TimeZone.getDefault(); } try { List<CalendarEvent> temp; if (request.getParameter("calView").equals("1")) { String[] cidList = request.getParameterValues("cidList"); Long viewdt1 = Long.parseLong(request.getParameter("viewdt1")); Long viewdt2 = Long.parseLong(request.getParameter("viewdt2")); int limit = Integer.parseInt(request.getParameter("limit")); int offset = Integer.parseInt(request.getParameter("start")); temp = calendarEventService.getEvents(cidList, new Date(viewdt1), new Date(viewdt2), offset, limit); } else { String[] cid = request.getParameterValues("cid"); temp = calendarEventService.getEvents(cid); } if (temp != null) { result = new ArrayList<CalendarEvent>(); for (CalendarEvent e : temp) { if (!e.isAllDay() && !(request.getParameter("calView").equals("1"))) { List durations = calendarEventService.breakDuration(e.getDuration(), tz); if (durations.size() > 1) result.addAll(calendarEventService.breakEvent(e, durations)); else result.add(e); } else { result.add(e); } } } StringBuffer usersList = sessionHandlerImpl.getRecursiveUsersList(request); if (moduleEventServices != null) { HashMap<String, Object> params = null; if (request.getParameter("calView").equals("1")) { params = new HashMap<String, Object>(); Long stDate = Long.parseLong(request.getParameter("viewdt1")); Long edDate = Long.parseLong(request.getParameter("viewdt2")); params.put("from", stDate); params.put("to", edDate); } for (ModuleEventService mes : moduleEventServices) { modEvents = mes.getEvents(usersList, params); if (modEvents != null) { for (CalendarEvent e : modEvents) { try { if (!e.isAllDay() && !(request.getParameter("calView").equals("1"))) { List durations = calendarEventService.breakDuration(e.getDuration(), tz); if (durations.size() > 1) result.addAll(calendarEventService.breakEvent(e, durations)); else result.add(e); } else { result.add(e); } } catch (Exception ev) { logger.warn(ev.getMessage()); } } } } } } catch (Exception e) { logger.warn(e.getMessage()); } SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); fmt.setTimeZone(tz); EventJSONMapper mapper = new EventJSONMapper(); mapper.setDateFormat(fmt); return new ModelAndView(new CalendarView(mapper, "data"), "data", result); }
From source file:com.clustercontrol.ws.notify.NotifyEndpoint.java
/** * ?????/*from w w w .j a v a 2 s.c o m*/ * * @param pluginId ID * @param monitorId ID * @param facilityId ID * @param subKey ??? * @param generationDate ? * @param priority ?? * @param application * @param message * @param messageOrg * @param notifyIdList ID? * @param srcId ?????ID * @throws InvalidRole * @throws InvalidUserPass * @throws HinemosUnknown * @throws NotifyNotFound * @throws FacilityNotFound */ public void notify(String pluginId, String monitorId, String facilityId, String subKey, long generationDate, int priority, String application, String message, String messageOrg, ArrayList<String> notifyIdList, String srcId) throws InvalidRole, InvalidUserPass, HinemosUnknown, NotifyNotFound, FacilityNotFound { SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); sdf.setTimeZone(HinemosTime.getTimeZone()); String msg = ", pluginID=" + pluginId + ", monitorID=" + monitorId + ", facilityID=" + facilityId + ", subKey=" + subKey + ", generationDate=" + sdf.format(new Date(generationDate)) + ", priority=" + priority + ", application=" + application + ", message=" + message + ", messageOrg=" + messageOrg + ", srcID=" + srcId; m_log.debug("notify() " + msg); // ??? try { new NotifyControllerBean().notify(pluginId, monitorId, facilityId, subKey, generationDate, priority, application, message, messageOrg, notifyIdList, srcId); } catch (Exception e) { m_opelog.warn(HinemosModuleConstant.LOG_PREFIX_NOTIFY + " Run Failed, Method=notify, User=" + HttpAuthenticator.getUserAccountString(wsctx) + msg.toString()); throw e; } m_opelog.info(HinemosModuleConstant.LOG_PREFIX_NOTIFY + " Run, Method=notify, User=" + HttpAuthenticator.getUserAccountString(wsctx) + msg.toString()); }
From source file:com.clustercontrol.calendar.composite.CalendarWeekComposite.java
/** * ?/* w ww.j av a 2 s . com*/ * ???? * @param key * @param y * @param endFlag * @param chkPointlbl */ private void addCheckPoint(long key, int y, boolean endFlag) { int timeZoneOffset = TimezoneUtil.getTimeZoneOffset(); long time = key + timeZoneOffset; if (time == 0 || time == DAY24) { return; } // SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); sdf.setTimeZone(TimezoneUtil.getTimeZone()); Label label = new Label(sdf.format(new Date(key))); label.setVisible(true); m_panel.add(label); Dimension dimension = new Dimension(-1, -1); int x = (int) (LEFT_MARGIN + time * MAX_BAR_LENGTH / DAY24); if (endFlag) { // x -= 55; // HH:mm:SS??????? x -= 35; } Point point = new Point(x, y); Rectangle rectangle = new Rectangle(point, dimension); m_panel.setConstraint(label, rectangle); }
From source file:com.hzq.car.CarTest.java
/** * ?//from w ww.j a va 2 s .c o m */ private String formatIso8601Date(Date date) { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); df.setTimeZone(new SimpleTimeZone(0, "GMT")); return df.format(date); }
From source file:com.fujitsu.dc.core.rs.box.BoxResource.java
/** * box????????????????????.//w w w. jav a 2s .com * @return ?JSON */ @SuppressWarnings("unchecked") private JSONObject createNotRequestedResponse() { JSONObject response = new JSONObject(); response.put("status", ProgressInfo.STATUS.COMPLETED.value()); response.put("schema", this.getBox().getSchema()); SimpleDateFormat sdfIso8601ExtendedFormatUtc = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); sdfIso8601ExtendedFormatUtc.setTimeZone(TimeZone.getTimeZone("UTC")); String installedAt = sdfIso8601ExtendedFormatUtc.format(new Date(this.getBox().getPublished())); response.put("installed_at", installedAt); return response; }
From source file:net.oddsoftware.android.feedscribe.data.Downloader.java
private HttpUriRequest createHttpRequest(String url, long resumeFrom, String eTag, Date lastModified) { HttpGet request = new HttpGet(url); request.setHeader("User-Agent", FeedManager.USER_AGENT); if (resumeFrom > 0) { request.setHeader("Range", "bytes=" + resumeFrom + "-"); }// www . j av a 2 s. c o m // send etag if we have it if (eTag != null && eTag.length() > 0) { request.setHeader("If-None-Match", eTag); } // send If-Modified-Since if we have it if (lastModified != null && lastModified.getTime() > 0) { SimpleDateFormat dateFormat = new SimpleDateFormat("EEE', 'dd' 'MMM' 'yyyy' 'HH:mm:ss' GMT'", Locale.US); dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); String formattedTime = dateFormat.format(lastModified); // If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT request.setHeader("If-Modified-Since", formattedTime); } return request; }
From source file:eu.codeplumbers.cosi.activities.NoteDetailsActivity.java
private void saveNoteAndSync() { SimpleDateFormat isoFormat = new SimpleDateFormat(DateUtils.DATE_FORMAT, Locale.FRANCE); isoFormat.setTimeZone(TimeZone.getTimeZone("UTC")); Date date = new Date(); if (note == null) { note = new Note(); note.setCreationDate(isoFormat.format(date)); note.setVersion(0);//from www .jav a 2 s .com note.setParentId("tree-node-all"); note.setRemoteId(""); } else { note.setVersion(note.getVersion() + 1); } getNoteTitle(isoFormat, date); }
From source file:org.adempiere.webui.dashboard.CalendarWindow.java
private void updateDateLabel() { Date b = calendars.getBeginDate(); Date e = calendars.getEndDate(); SimpleDateFormat sdfV = DisplayType.getDateFormat(); sdfV.setTimeZone(calendars.getDefaultTimeZone()); lblDate.setValue(sdfV.format(b) + " - " + sdfV.format(e)); }