public boolean checkMoment(Date date) { if (calendar != null) { Period period = new Period(new DateTime(date), new Dur(0, 0, 0, 0)); Predicate<CalendarComponent> periodRule = new PeriodRule<>(period); Filter<CalendarComponent> filter = new Filter<>(new Predicate[] {periodRule}, Filter.MATCH_ANY); Collection<CalendarComponent> events = filter.filter(calendar.getComponents(CalendarComponent.VEVENT)); if (events != null && !events.isEmpty()) { return true; } } return false; }
/** * @param name a property name * @param parameters list of parameters */ public UtcProperty(final String name, final ParameterList parameters, PropertyFactory factory) { super(name, parameters, factory); setDate(new DateTime(true)); }
/** * @param name a property name */ public UtcProperty(final String name, PropertyFactory factory) { super(name, factory); setDate(new DateTime(true)); }
/** * @param name a property name */ public UtcProperty(final String name, PropertyFactory factory) { super(name, factory); setDate(new DateTime(true)); }
/** * Default constructor. The time value is initialised to the time of instantiation. */ public Due() { super(DUE, new Factory()); // defaults to UTC time.. setDate(new DateTime(true)); }
/** * Default constructor. */ public RecurrenceId() { super(RECURRENCE_ID, new Factory()); setDate(new DateTime()); }
private DateTime calculateOnset(String dateStr) throws ParseException { // Translate local onset into UTC time by parsing local time // as GMT and adjusting by TZOFFSETFROM if required long utcOnset; synchronized (UTC_FORMAT) { utcOnset = UTC_FORMAT.parse(dateStr).getTime(); } // return a UTC DateTime onset = new DateTime(true); onset.setTime(utcOnset); return onset; }
/** * Default constructor. The time value is initialised to the time of instantiation. */ public Due() { super(DUE, PropertyFactoryImpl.getInstance()); // defaults to UTC time.. setDate(new DateTime(true)); }
private DateTime calculateOnset(String dateStr) throws ParseException { // Translate local onset into UTC time by parsing local time // as GMT and adjusting by TZOFFSETFROM if required long utcOnset; synchronized (UTC_FORMAT) { utcOnset = UTC_FORMAT.parse(dateStr).getTime(); } // return a UTC DateTime onset = new DateTime(true); onset.setTime(utcOnset); return onset; }
private DateTime calculateOnset(String dateStr) throws ParseException { // Translate local onset into UTC time by parsing local time // as GMT and adjusting by TZOFFSETFROM if required long utcOnset; synchronized (UTC_FORMAT) { utcOnset = UTC_FORMAT.parse(dateStr).getTime(); } // return a UTC DateTime onset = new DateTime(true); onset.setTime(utcOnset); return onset; }
/** * Default constructor. */ public RecurrenceId() { super(RECURRENCE_ID, new Factory()); setDate(new DateTime()); }
/** * Default constructor. The time value is initialised to the time of instantiation. */ public Due() { super(DUE, PropertyFactoryImpl.getInstance()); // defaults to UTC time.. setDate(new DateTime(true)); }
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")); }
public final void test3() { java.util.Calendar cal = getCalendarInstance(); // tomorrow.. cal.add(java.util.Calendar.DAY_OF_MONTH, 1); cal.set(java.util.Calendar.HOUR_OF_DAY, 9); cal.set(java.util.Calendar.MINUTE, 30); VEvent meeting = new VEvent(new DateTime(cal.getTime().getTime()), java.time.Duration.ofHours(1), "Progress Meeting"); // add timezone information.. meeting.getProperty(Property.DTSTART).getParameters().add(tzParam); log.info(meeting.toString()); }
private DateTime applyOffsetFrom(DateTime orig) { DateTime withOffset = new DateTime(true); withOffset.setTime(orig.getTime() - (getOffsetFrom().getOffset().getTotalSeconds() * 1000L)); return withOffset; } }
/** * Unit tests for {@link Period#isEmpty()}. */ public void testIsEmpty() { Calendar cal = Calendar.getInstance(); DateTime start = new DateTime(cal.getTime()); assertTrue(new Period(start, start).isEmpty()); assertTrue(new Period(start, java.time.Period.ZERO).isEmpty()); cal.add(Calendar.SECOND, 1); assertFalse(new Period(start, new DateTime(cal.getTime())).isEmpty()); assertFalse(new Period(start, java.time.Duration.ofSeconds(1)).isEmpty()); }
/** * A test to confirm that the end date is calculated correctly * from a given start date and duration, even when timezone is specified. */ public final void testEventEndDateWithTimeZone() throws ParseException { TimeZone timezone = new TimeZoneRegistryImpl().getTimeZone("Asia/Seoul"); DateTime startDateTime = new DateTime("20181003T130000", timezone); log.info("Start date: " + startDateTime); VEvent event = new VEvent(startDateTime, java.time.Duration.ofHours(1), "1 hour event"); assertEquals(new DateTime("20181003T140000", timezone), event.getEndDate().getDate()); }
public void testZuluToLocal() throws Exception { DateTime d = new DateTime(zuluDateTimeStr); d.setTimeZone(timezone); assertEquals(expectedLocalDateTimeStr, d.toString()); }
/** * Unit tests for value/timezone constructor. */ public void testDtStartStringTimezone() throws ParseException { String value = new DateTime().toString(); DtStart dtStart = new DtStart(value, timezone); assertEquals(timezone, dtStart.getTimeZone()); assertEquals(value, dtStart.getValue()); }
/** * Unit tests for timezone constructor. */ public void testDtStartTimezone() throws ParseException { DtStart dtStart = new DtStart(timezone); dtStart.setValue(new DateTime().toString()); assertEquals(timezone, dtStart.getTimeZone()); // initialising with DATE value should reset timezone.. dtStart.setDate(new Date()); assertNull(dtStart.getTimeZone()); }