public static TimeZone getUTCTimeZone() { return registry.getTimeZone("UTC"); }
/** * @return The timeZone (ical4j) built of the default java timeZone of the user. * @see ThreadLocalUserContext#getTimeZone() */ public static TimeZone getTimeZone(final java.util.TimeZone timeZone) { return registry.getTimeZone(timeZone.getID()); }
/** * @return The timeZone (ical4j) built of the default java timeZone of the user. * @see ThreadLocalUserContext#getTimeZone() */ public static TimeZone getUserTimeZone() { return registry.getTimeZone(ThreadLocalUserContext.getTimeZone().getID()); }
/** * Set the timezone to use when converting floating times to * UTC. Only used if isUTC is set to true. * * @param timezone The timezone. */ public void setTimezone(TimeZone timezone) { if(timezone != null ){ this.timezone = TimeZoneRegistryFactory.getInstance().createRegistry().getTimeZone(timezone.getID()); } }
/** * Set the timezone to use when converting floating times to * UTC. Only used if isUTC is set to true. * * @param timezone The timezone. */ public void setTimezone(TimeZone timezone) { if(timezone != null ){ this.timezone = TimeZoneRegistryFactory.getInstance().createRegistry().getTimeZone(timezone.getID()); } }
public void parameter(final String name, final String value) throws URISyntaxException { assertProperty(property); // parameter names are case-insensitive, but convert to upper case to simplify further processing final Parameter param = parameterFactory.createParameter(name.toUpperCase(), Strings.escapeNewline(value)); property.getParameters().add(param); if (param instanceof TzId && tzRegistry != null && !(property instanceof XProperty)) { final TimeZone timezone = tzRegistry.getTimeZone(param.getValue()); if (timezone != null) { updateTimeZone(property, timezone); } else { // VTIMEZONE may be defined later, so so keep // track of dates until all components have been // parsed, and then try again later datesMissingTimezones.add(property); } } }
public void testAmericaIndiana() { java.util.TimeZone indianaTz = java.util.TimeZone .getTimeZone("America/Indiana/Indianapolis"); Calendar cal = Calendar.getInstance(indianaTz); cal.set(Calendar.HOUR_OF_DAY, 10); cal.set(Calendar.MINUTE, 20); DateTime dtStart = new DateTime(cal.getTime()); DtStart pDtStart = new DtStart(dtStart); pDtStart.setTimeZone(registry .getTimeZone("America/Indiana/Indianapolis")); }
protected void setUp() throws Exception { super.setUp(); TimeZoneRegistry tzReg = TimeZoneRegistryFactory.getInstance().createRegistry(); timezone = tzReg.getTimeZone("Australia/Melbourne"); }
@Override void mapToCard(net.fortuna.ical4j.model.Calendar cal, Object bean, PropertyDescriptor pd) { TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry(); String tzId = propertyAccessor.get(bean, pd.getReadMethod(), String.class); TimeZone timezone = null; if (tzId != null && tzId.length() > 0) { timezone = registry.getTimeZone(tzId); // Eg Pacific/Auckland } // TODO: do we need to use a default time zone if none given? if (timezone != null) { VTimeZone tz = timezone.getVTimeZone(); cal.getComponents().add(tz); } } }
/** * @param testMethod * @param timezoneId */ public TimeZoneTest(String testMethod, String timezoneId) { super(testMethod); // java.util.TimeZone.setDefault(java.util.TimeZone.getTimeZone("America/Los_Angeles")); registry = TimeZoneRegistryFactory.getInstance().createRegistry(); tz = java.util.TimeZone.getTimeZone(timezoneId); timezone = registry.getTimeZone(timezoneId); }
public void testTimeString() throws ParseException { Time time = new Time("020000", registry.getTimeZone("America/Los_Angeles")); Assert.assertEquals("020000", time.toString()); } }
public void testDateTimeString() throws Exception { try { new DateTime("20050630"); fail("Should throw ParseException"); } catch (ParseException pe) { log.info("Exception occurred: " + pe.getMessage()); } try { new DateTime("20000402T020000", registry.getTimeZone("America/Los_Angeles")); fail("Should throw ParseException"); } catch (ParseException pe) { log.info("Exception occurred: " + pe.getMessage()); } }
@Before public void setUp() throws Exception { TimeZoneRegistry tzReg = TimeZoneRegistryFactory.getInstance().createRegistry(); timezone = tzReg.getTimeZone("Australia/Melbourne"); }
@Override public Property toVEvent(final TeamEventDO event) { if (event.isAllDay() == true) { final Date startUtc = CalendarUtils.getUTCMidnightDate(event.getStartDate()); net.fortuna.ical4j.model.Date date = new net.fortuna.ical4j.model.Date(startUtc); return new DtStart(date); } else { DateTime date = new DateTime(event.getStartDate()); date.setTimeZone(TIMEZONE_REGISTRY.getTimeZone(event.getTimeZone().getID())); return new DtStart(date); } }
private void initDateProp(final DateProperty dt, final TimeZoneRegistry tzreg) throws CalFacadeException { try { String tzid = getTzid(); ParameterList pl = dt.getParameters(); if (getDateType()) { pl.add(Value.DATE); } if (tzid != null) { dt.setTimeZone(tzreg.getTimeZone(tzid)); } dt.setValue(getDtval()); } catch (Throwable t) { throw new CalFacadeException(t); } }
/** * @return */ public static TestSuite suite() { TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry(); TestSuite suite = new TestSuite(); suite.addTest(new VTimeZoneTest("testCreateDefinition", registry.getTimeZone("Australia/Melbourne").getVTimeZone())); VTimeZone tz = new VTimeZone(); suite.addTest(new VTimeZoneTest("testIsCalendarComponent", tz)); suite.addTest(new VTimeZoneTest("testValidationException", tz)); return suite; } }
protected void setUp() throws Exception { super.setUp(); // relax validation to avoid UID requirement.. CompatibilityHints.setHintEnabled( CompatibilityHints.KEY_RELAXED_VALIDATION, true); registry = TimeZoneRegistryFactory.getInstance().createRegistry(); // create timezone property.. tz = registry.getTimeZone("Australia/Melbourne").getVTimeZone(); // create tzid parameter.. tzParam = new TzId(tz.getProperty(Property.TZID) .getValue()); }
public void setUp() throws Exception { super.setUp(); // relax validation to avoid UID requirement.. CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_VALIDATION, true); TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry(); // create timezone property.. VTimeZone tz = registry.getTimeZone("Australia/Melbourne").getVTimeZone(); // create tzid parameter.. tzParam = new TzId(tz.getProperty(Property.TZID).getValue()); }
/** * @return */ public static TestSuite suite() throws ParseException { TimeZoneRegistry tzReg = DefaultTimeZoneRegistryFactory.getInstance() .createRegistry(); TestSuite suite = new TestSuite(); ExDate exZulu = new ExDate(); exZulu.setValue("20111212T000000Z"); suite.addTest(new DateListPropertyTest("testCopy", exZulu)); ExDate exMelbourne = new ExDate(); exMelbourne.setTimeZone(tzReg.getTimeZone("Australia/Melbourne")); exMelbourne.setValue("20111212T000000"); suite.addTest(new DateListPropertyTest("testCopy", exMelbourne)); return suite; } }
/** * Test that equality of two DateTime instances created using different constructors * implies equality of hashCode. * * @throws ParseException */ public void testDateTimeHashCode() throws ParseException { TimeZone tz1 = TimeZoneRegistryFactory.getInstance().createRegistry().getTimeZone("Europe/Paris"); TimeZone tz2 = (TimeZone) tz1.clone(); DateTime date1 = new DateTime("20050101T093000", tz1); DateTime date2 = new DateTime("20050101T093000", tz2); // verify that if equals() == true, hashCode must match also // was not the case previously as hashCode() was taking the TimeZone object // into consideration when equals() was not. assertEquals(date1, date2); assertEquals(date1.hashCode(), date2.hashCode()); }