List of usage examples for java.util TimeZone getID
public String getID()
From source file:ch.cyberduck.core.ftp.FTPParserFactory.java
private CompositeFileEntryParser createNetwareFTPEntryParser(final TimeZone timezone) { return new CompositeFileEntryParser(Arrays.asList(new NetwareFTPEntryParser() { @Override/*from ww w. ja va2 s . c o m*/ protected FTPClientConfig getDefaultConfiguration() { final FTPClientConfig config = super.getDefaultConfiguration(); config.setServerTimeZoneId(timezone.getID()); return config; } }, this.createUnixFTPEntryParser(timezone))); }
From source file:com.cubusmail.gwtui.server.services.UserAccountService.java
public String[][] retrieveTimezones() { NumberFormat format = new DecimalFormat("00"); Locale locale = SessionManager.get().getLocale(); ResourceBundle bundle = ConvertUtil.getTimezonesBundle(locale); Enumeration<String> ids = bundle.getKeys(); List<TimeZone> timeZoneList = toSortedZimeZoneList(ids); String[][] result = new String[timeZoneList.size()][2]; int index = 0; for (TimeZone timeZone : timeZoneList) { result[index][0] = timeZone.getID(); String hours = format.format(timeZone.getRawOffset() / 3600000); if (timeZone.getRawOffset() >= 0) { result[index][1] = "(+" + hours + ":00) " + bundle.getString(timeZone.getID()); } else {/*from w w w .j av a2 s . c o m*/ result[index][1] = "(" + hours + ":00) " + bundle.getString(timeZone.getID()); } index++; } return result; }
From source file:architecture.ee.component.core.lifecycle.ConfigServiceImpl.java
/** * @param newTimeZone/* w w w . ja v a 2 s .com*/ */ public void setTimeZone(TimeZone newTimeZone) { String timeZoneId = newTimeZone.getID(); setApplicationProperty(ApplicationConstants.LOCALE_TIMEZONE_PROP_NAME, timeZoneId); resetL10N(); }
From source file:com.microsoft.exchange.DateHelpTest.java
@Test public void getXMLGregorianCalendarsForTimeZones() throws DatatypeConfigurationException { List<String> availableIDs = Arrays.asList(TimeZone.getAvailableIDs()); for (String timeZoneID : availableIDs) { TimeZone currTimeZone = TimeZone.getTimeZone(timeZoneID); XMLGregorianCalendar currXmlCalendar = DateHelp.getXMLGregorianCalendarNow(currTimeZone); boolean match = xmlGregorianCalendareMatchesTimeZone(currXmlCalendar, currTimeZone); if (!match) log.info(currTimeZone.getID() + " " + (match ? "PASSED" : "FAILED")); }//from w w w.j a va2 s .co m }
From source file:ch.cyberduck.core.ftp.FTPParserFactory.java
private CompositeFileEntryParser createUnixFTPEntryParser(final TimeZone timezone) { return new CompositeFileEntryParser(Arrays.asList(new LaxUnixFTPEntryParser() { @Override//from w w w . j av a 2 s .co m protected FTPClientConfig getDefaultConfiguration() { final FTPClientConfig config = super.getDefaultConfiguration(); config.setServerTimeZoneId(timezone.getID()); return config; } }, new EPLFFTPEntryParser(), new RumpusFTPEntryParser() { @Override protected FTPClientConfig getDefaultConfiguration() { final FTPClientConfig config = super.getDefaultConfiguration(); config.setServerTimeZoneId(timezone.getID()); return config; } }, new TrellixFTPEntryParser() { @Override protected FTPClientConfig getDefaultConfiguration() { final FTPClientConfig config = super.getDefaultConfiguration(); config.setServerTimeZoneId(timezone.getID()); return config; } }, new UnitreeFTPEntryParser() { @Override protected FTPClientConfig getDefaultConfiguration() { final FTPClientConfig config = super.getDefaultConfiguration(); config.setServerTimeZoneId(timezone.getID()); return config; } })); }
From source file:com.concursive.connect.web.modules.calendar.utils.DimDimUtils.java
/** * Calls Dimdim server methods based on the action set on MeetingInviteesBean * * @param meetingInviteesBean - meeting parameters to be called are to be set to the class * @param attendeeUser - host or participant based on the meeting action * @return - Url to dimdim server or the message returned */// w w w . j ava 2 s. c o m public static HashMap<String, String> processDimdimMeeting(MeetingInviteesBean meetingInviteesBean, User attendeeUser) { //return result HashMap<String, String> resultMap = new HashMap<String, String>(); try { //get meeting Meeting meeting = meetingInviteesBean.getMeeting(); //get meeting host User hostUser = UserUtils.loadUser(meeting.getOwner()); //comma separate the attendee mailids for dimdim String attendeeMailIds = ""; if (meetingInviteesBean.getMembersFoundList() != null && meetingInviteesBean.getMembersFoundList().size() > 0) { Set<User> userSet = meetingInviteesBean.getMembersFoundList().keySet(); for (User user : userSet) { attendeeMailIds += user.getEmail() + ", "; } } if (meetingInviteesBean.getMeetingChangeUsers() != null && meetingInviteesBean.getMeetingChangeUsers().size() > 0) { for (User user : meetingInviteesBean.getMeetingChangeUsers()) { attendeeMailIds += user.getEmail() + ", "; } } attendeeMailIds = trimComma(attendeeMailIds); //Modify meeting if (meetingInviteesBean.getAction() == ACTION_MEETING_DIMDIM_EDIT || meetingInviteesBean.getAction() == ACTION_MEETING_APPROVE_JOIN) { //check for meetingId if not present then call schedule meeting if (!StringUtils.hasText(meeting.getDimdimMeetingId())) { meetingInviteesBean.setAction(ACTION_MEETING_DIMDIM_SCHEDULE); resultMap = processDimdimMeeting(meetingInviteesBean, attendeeUser); meetingInviteesBean.setAction(ACTION_MEETING_DIMDIM_EDIT); return resultMap; } //set the query string values as params Map<String, String> params = new HashMap<String, String>(); params.put("name", meeting.getDimdimUsername()); params.put("password", meeting.getDimdimPassword()); params.put("meetingID", meeting.getDimdimMeetingId()); SimpleDateFormat dtFormater = new SimpleDateFormat("MMMM dd, yyyy"); TimeZone timeZone = Calendar.getInstance().getTimeZone(); if (hostUser.getTimeZone() != null) { timeZone = TimeZone.getTimeZone(hostUser.getTimeZone()); } Calendar calendar = Calendar.getInstance(timeZone); calendar.setTime(meeting.getStartDate()); params.put("startDate", dtFormater.format(meeting.getStartDate())); params.put("endDate", dtFormater.format(meeting.getEndDate())); params.put("startHour", calendar.get(Calendar.HOUR) + ""); params.put("startMinute", calendar.get(Calendar.MINUTE) + ""); params.put("timeAMPM", calendar.get(Calendar.AM_PM) == 0 ? "AM" : "PM"); params.put("confname", meeting.getTitle()); params.put("timezone", timeZone.getID()); params.put("feedback", hostUser.getEmail()); if (StringUtils.hasText(attendeeMailIds)) { params.put("attendees", attendeeMailIds); } params.put("agenda", meeting.getDescription()); if (meeting.getByInvitationOnly()) { params.put("attendeePwd", meeting.getDimdimMeetingKey()); params.put("waitingarea", "false"); } else { params.put("attendeePwd", ""); params.put("waitingarea", "false"); } params.put("response", "json"); //post to dimdim server and process response LOG.debug("JSON POST"); String urlPrefix = meeting.getDimdimUrl() + URL_DIMDIM_EDIT; JSONObject dimdimResp = JSONObject.fromObject(HTTPUtils.post(urlPrefix, params)); String resSuccess = dimdimResp.getString("code"); String resText = dimdimResp.getJSONObject("data").getString("text"); //get meetingid if successful if (DIMDIM_CODE_SUCCESS.equals(resSuccess)) { resultMap.put(resSuccess, meeting.getDimdimMeetingId()); return resultMap; } resultMap.put(resSuccess, resText); return resultMap; } //create a new meeting if (meetingInviteesBean.getAction() == ACTION_MEETING_DIMDIM_SCHEDULE) { //set the query string values as params Map<String, String> params = new HashMap<String, String>(); params.put("name", meeting.getDimdimUsername()); params.put("password", meeting.getDimdimPassword()); SimpleDateFormat dtFormater = new SimpleDateFormat("MMMM dd, yyyy"); TimeZone timeZone = Calendar.getInstance().getTimeZone(); if (hostUser.getTimeZone() != null) { timeZone = TimeZone.getTimeZone(hostUser.getTimeZone()); } Calendar calendar = Calendar.getInstance(timeZone); calendar.setTime(meeting.getStartDate()); params.put("startDate", dtFormater.format(meeting.getStartDate())); params.put("endDate", dtFormater.format(meeting.getEndDate())); params.put("startHour", calendar.get(Calendar.HOUR) + ""); params.put("startMinute", calendar.get(Calendar.MINUTE) + ""); params.put("timeAMPM", calendar.get(Calendar.AM_PM) == 0 ? "AM" : "PM"); params.put("confname", meeting.getTitle()); params.put("timezone", timeZone.getID()); params.put("feedback", hostUser.getEmail()); if (StringUtils.hasText(attendeeMailIds)) { params.put("attendees", attendeeMailIds); } params.put("agenda", meeting.getDescription()); if (StringUtils.hasText(meeting.getDimdimMeetingKey())) { params.put("attendeePwd", meeting.getDimdimMeetingKey()); params.put("waitingarea", "false"); } params.put("response", "json"); //post to dimdim server and process response LOG.debug("JSON POST"); String urlPrefix = meeting.getDimdimUrl() + URL_DIMDIM_SCHEDULE; JSONObject dimdimResp = JSONObject.fromObject(HTTPUtils.post(urlPrefix, params)); String resSuccess = dimdimResp.getString("code"); String resText = dimdimResp.getJSONObject("data").getString("text"); //get meetingid if successful if (DIMDIM_CODE_SUCCESS.equals(resSuccess)) { resText = resText.substring(resText.lastIndexOf("is ") + 3); resultMap.put(resSuccess, resText); return resultMap; } resultMap.put(resSuccess, resText); return resultMap; } //join an existing meeting if (meetingInviteesBean.getAction() == ACTION_MEETING_DIMDIM_JOIN) { //set the query string values as params Map<String, String> params = new HashMap<String, String>(); params.put("meetingRoomName", meeting.getDimdimUsername()); params.put("displayname", attendeeUser.getNameFirstLast()); if (StringUtils.hasText(meeting.getDimdimMeetingKey())) { params.put("attendeePwd", meeting.getDimdimMeetingKey()); } params.put("response", "json"); //post to dimdim server and process response LOG.debug("JSON POST"); String urlPrefix = meeting.getDimdimUrl() + URL_DIMDIM_JOIN; JSONObject dimdimResp = JSONObject.fromObject(HTTPUtils.post(urlPrefix, params)); String resSuccess = dimdimResp.getString("code"); String resText = dimdimResp.getJSONObject("data").getString("text"); //if successful return dimdim url if (DIMDIM_CODE_SUCCESS.equals(resSuccess)) { resultMap.put(resSuccess, urlPrefix + buildDimdimUrl(params)); return resultMap; } resultMap.put(resSuccess, resText); return resultMap; } //start a meeting if (meetingInviteesBean.getAction() == ACTION_MEETING_DIMDIM_START) { //set the query string values as params Map<String, String> params = new HashMap<String, String>(); params.put("name", meeting.getDimdimUsername()); params.put("password", meeting.getDimdimPassword()); params.put("meetingID", meeting.getDimdimMeetingId()); params.put("response", "json"); //post to dimdim server and process response LOG.debug("JSON POST"); String urlPrefix = meeting.getDimdimUrl() + URL_DIMDIM_START; JSONObject dimdimResp = JSONObject.fromObject(HTTPUtils.post(urlPrefix, params)); String resSuccess = dimdimResp.getString("code"); String resText = dimdimResp.getJSONObject("data").getString("text"); if (DIMDIM_CODE_SUCCESS.equals(resSuccess)) { resultMap.put(resSuccess, urlPrefix + buildDimdimUrl(params)); return resultMap; } resultMap.put(resSuccess, resText); return resultMap; } //delete a meeting if (meetingInviteesBean.getAction() == ACTION_MEETING_DIMDIM_CANCEL) { //set the query string values as params Map<String, String> params = new HashMap<String, String>(); params.put("name", meeting.getDimdimUsername()); params.put("password", meeting.getDimdimPassword()); params.put("meetingID", meeting.getDimdimMeetingId()); params.put("response", "json"); //post to dimdim server and process response LOG.debug("JSON POST"); String urlPrefix = meeting.getDimdimUrl() + URL_DIMDIM_DELETE; JSONObject dimdimResp = JSONObject.fromObject(HTTPUtils.post(urlPrefix, params)); String resSuccess = dimdimResp.getString("code"); String resText = dimdimResp.getJSONObject("data").getString("text"); if (DIMDIM_CODE_SUCCESS.equals(resSuccess)) { resultMap.put(resSuccess, urlPrefix + buildDimdimUrl(params)); return resultMap; } resultMap.put(resSuccess, resText); return resultMap; } LOG.error("Unknown Dimdim meeting senario or action."); resultMap.put("0", "Error occured while accessing Dimdim server."); return resultMap; } catch (Exception e) { LOG.error(e.toString()); resultMap.put("0", "Error occured while accessing Dimdim server."); return resultMap; } }
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 va2s . c o m*/ 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()); }
From source file:edu.harvard.i2b2.query.data.QueryConceptTreePanelData.java
public ConstrainByDate writeTimeConstraint() { ConstrainByDate timeConstrain = new ConstrainByDate(); DTOFactory dtoFactory = new DTOFactory(); TimeZone tz = Calendar.getInstance().getTimeZone(); GregorianCalendar cal = new GregorianCalendar(tz); //cal.get(Calendar.ZONE_OFFSET); int zt_offset = (cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET)) / 60000; log.info("Timezone: " + tz.getID() + " : " + zt_offset); if (startTime() != -1) { ConstrainDateType constraindateType = new ConstrainDateType(); XMLGregorianCalendar xmlC = dtoFactory.getXMLGregorianCalendarDate(startYear(), startMonth() + 1, startDay());//from w w w. j a v a2s. c o m xmlC.setTimezone(zt_offset);//0);//-5*60); xmlC.setHour(0); xmlC.setMinute(0); xmlC.setSecond(0); constraindateType.setValue(xmlC); timeConstrain.setDateFrom(constraindateType); } if (endTime() != -1) { ConstrainDateType constraindateType = new ConstrainDateType(); XMLGregorianCalendar xmlC = dtoFactory.getXMLGregorianCalendarDate(endYear(), endMonth() + 1, endDay()); xmlC.setTimezone(zt_offset);//0);//-5*60); xmlC.setHour(0); xmlC.setMinute(0); xmlC.setSecond(0); constraindateType.setValue(xmlC); timeConstrain.setDateTo(constraindateType); } return timeConstrain; }
From source file:com.appeligo.search.actions.BaseAction.java
protected void setTimeZone(TimeZone timeZone) { getServletRequest().getSession().setAttribute(TIMEZONE_ID, timeZone); Cookie cookie = new Cookie(TIMEZONE_ID, timeZone.getID()); cookie.setMaxAge(Integer.MAX_VALUE); response.addCookie(cookie);/*from ww w.j a v a 2 s . c o m*/ }
From source file:org.betaconceptframework.astroboa.test.model.query.parser.CriterionParserTest.java
/** * If provided value is a valid ISO8601 date then equivalent calendar is returned * /* www .j a v a2 s .co m*/ * @param value * @return * @throws ParseException */ private Calendar checkIfValueIsISO8601Date(String value) { if (StringUtils.isBlank(value)) { return null; } Calendar date = null; try { Matcher dateTimeMatcher = ISO8601Pattern.matcher(value); if (dateTimeMatcher.matches()) { StringBuilder pattern = new StringBuilder("yyyy-MM-dd'T'HH:mm:ss"); String timeZoneId = null; //We must decide which pattern to use //At this point this is the minimum //Group 7 corresponds to milli seconds if (dateTimeMatcher.groupCount() >= 7 && dateTimeMatcher.group(7) != null) { pattern.append(".SSS"); } if (dateTimeMatcher.groupCount() >= 8 && dateTimeMatcher.group(8) != null) { if (!"Z".equals(dateTimeMatcher.group(8))) { //Keep UTC info to look for time zone when Calendar object will be created, //as SimpleDateformat which is used in DateUtils //cannot handle time zone designator timeZoneId = "GMT" + dateTimeMatcher.group(8); value = value.replace(dateTimeMatcher.group(8), ""); } else { timeZoneId = "GMT"; value = value.replace("Z", ""); } } date = (Calendar) DateUtils.fromString(value, pattern.toString()); if (timeZoneId != null) { //Now that date is found we should define its TimeZone TimeZone timeZone = TimeZone.getTimeZone(timeZoneId); if (!timeZone.getID().equals(timeZoneId)) { // Time Zone is not valid throw new CmsException("Invalid time zone in date value " + value); } date.setTimeZone(timeZone); } } else { //check for simple date Matcher dateMatcher = ISO8601DatePattern.matcher(value); if (dateMatcher.matches()) { date = (Calendar) DateUtils.fromString(value, ISO8601_DATE_FORMAT); } } } catch (Exception e) { //Probably not a date value. Ignore exception return null; } return date; }