public static java.sql.Date getSqlDate(final net.fortuna.ical4j.model.Date ical4jDate) { if (ical4jDate == null) { return null; } return new java.sql.Date(ical4jDate.getTime()); }
public static java.sql.Timestamp getSqlTimestamp(final net.fortuna.ical4j.model.Date ical4jDate) { if (ical4jDate == null) { return null; } return new java.sql.Timestamp(ical4jDate.getTime()); }
/** * Returns a cached onset for the specified date. * @param date * @return a cached onset date or null if no cached onset is applicable for the specified date */ private DateTime getCachedOnset(final Date date) { int index = Arrays.binarySearch(onsetsMillisec, date.getTime()); if (index >= 0) { return onsetsDates[index]; } else { int insertionIndex = -index -1; return onsetsDates[insertionIndex -1]; } }
/** * Returns a cached onset for the specified date. * * @param date * @return a cached onset date or null if no cached onset is applicable for the specified date */ private DateTime getCachedOnset(final Date date) { int index = Arrays.binarySearch(onsetsMillisec, date.getTime()); if (index >= 0) { return onsetsDates[index]; } else { int insertionIndex = -index - 1; return onsetsDates[insertionIndex - 1]; } }
/** * Returns a cached onset for the specified date. * * @param date * @return a cached onset date or null if no cached onset is applicable for the specified date */ private DateTime getCachedOnset(final Date date) { int index = Arrays.binarySearch(onsetsMillisec, date.getTime()); if (index >= 0) { return onsetsDates[index]; } else { int insertionIndex = -index - 1; return onsetsDates[insertionIndex - 1]; } }
/** * Returns a cached onset for the specified date. * * @param date * @return a cached onset date or null if no cached onset is applicable for the specified date */ private DateTime getCachedOnset(final Date date) { int index = Arrays.binarySearch(onsetsMillisec, date.getTime()); if (index >= 0) { return onsetsDates[index]; } else { int insertionIndex = -index - 1; return onsetsDates[insertionIndex - 1]; } }
/** * Returns a cached onset for the specified date. * * @param date * @return a cached onset date or null if no cached onset is applicable for the specified date */ private DateTime getCachedOnset(final Date date) { int index = Arrays.binarySearch(onsetsMillisec, date.getTime()); if (index >= 0) { return onsetsDates[index]; } else { int insertionIndex = -index - 1; return onsetsDates[insertionIndex - 1]; } }
private void copyDateProperty(ContentValues c, String dbName, String dbTzName, DateProperty date) { if (dbName != null && date.getDate() != null) { c.put(dbName, date.getDate().getTime()); // ms since epoc in GMT if (dbTzName != null) { if (date.isUtc() || date.getTimeZone() == null) c.put(dbTzName, "UTC"); else c.put(dbTzName, date.getTimeZone().getID()); } } }
@Override public boolean fromVEvent(final TeamEventDO event, final VEvent vEvent) { if (vEvent.getDateStamp() != null) { event.setDtStamp(new Timestamp(vEvent.getDateStamp().getDate().getTime())); return true; } return false; } }
/** * @return a version value in microsecords. */ @NoDump public long getMicrosecsVersion() throws CalFacadeException { try { final String[] ct = getCtoken().split("-"); return new LastModified(ct[0]).getDate().getTime() * 1000000 + Integer.parseInt(ct[1], 16) * 100; } catch (final Throwable t) { throw new CalFacadeException(t); } }
/** * Calculate rank of NoteItem. Rank is the absolute value of the * triageStatus rank. If triageStatus rank is not present, then * it is the value in milliseconds of the start time of the event. * If the note is not an event then it is the last modified date. */ private long getRank(NoteItem note) { // Use triageStatusRank * 1000 to normalize to // unix timestamp in milliseconds. if(note.getTriageStatus()!=null && note.getTriageStatus().getRank()!=null) { return note.getTriageStatus().getRank().scaleByPowerOfTen(3).longValue(); } // otherwise use startDate * -1 BaseEventStamp eventStamp = StampUtils.getBaseEventStamp(note); if(eventStamp!=null) { return eventStamp.getStartDate().getTime()*-1; } // or occurrence date * -1 if(note instanceof NoteOccurrence) { return ((NoteOccurrence) note).getOccurrenceDate().getTime()*-1; } // use modified date * -1 as a last resort return note.getModifiedDate().getTime()*-1; } }
@Override public Property toVEvent(final TeamEventDO event) { net.fortuna.ical4j.model.Date date; if (event.isAllDay() == true) { final Date endUtc = CalendarUtils.getUTCMidnightDate(event.getEndDate()); final org.joda.time.DateTime jodaTime = new org.joda.time.DateTime(endUtc); // TODO sn should not be done // requires plus 1 because one day will be omitted by calendar. final net.fortuna.ical4j.model.Date fortunaEndDate = new net.fortuna.ical4j.model.Date(jodaTime.plusDays(1).toDate()); date = new net.fortuna.ical4j.model.Date(fortunaEndDate.getTime()); } else { date = new DateTime(event.getEndDate()); ((net.fortuna.ical4j.model.DateTime) date).setTimeZone(TIMEZONE_REGISTRY.getTimeZone(event.getTimeZone().getID())); } return new DtEnd(date); }
/** * Calculate rank of NoteItem. Rank is the absolute value of the * triageStatus rank. If triageStatus rank is not present, then * it is the value in milliseconds of the start time of the event. * If the note is not an event then it is the last modified date. */ private long getRank(NoteItem note) { // Use triageStatusRank * 1000 to normalize to // unix timestamp in milliseconds. if(note.getTriageStatus()!=null && note.getTriageStatus().getRank()!=null) { return note.getTriageStatus().getRank().scaleByPowerOfTen(3).longValue(); } // otherwise use startDate * -1 BaseEventStamp eventStamp = StampUtils.getBaseEventStamp(note); if(eventStamp!=null) { return eventStamp.getStartDate().getTime()*-1; } // or occurrence date * -1 if(note instanceof NoteOccurrence) { return ((NoteOccurrence) note).getOccurrenceDate().getTime()*-1; } // use modified date * -1 as a last resort return note.getModifiedDate().getTime()*-1; } }
@Override public boolean fromVEvent(final TeamEventDO event, final VEvent vEvent) { final boolean isAllDay = this.isAllDay(vEvent); if (vEvent.getProperties().getProperties(Property.DTEND).isEmpty()) { return false; } if (isAllDay) { // TODO sn change behaviour to iCal standard final org.joda.time.DateTime jodaTime = new org.joda.time.DateTime(vEvent.getEndDate().getDate()); final net.fortuna.ical4j.model.Date fortunaEndDate = new net.fortuna.ical4j.model.Date(jodaTime.plusDays(-1).toDate()); event.setEndDate(new Timestamp(fortunaEndDate.getTime())); } else { event.setEndDate(ICal4JUtils.getSqlTimestamp(vEvent.getEndDate().getDate())); } return true; } }
/** * @return a version value in microseconds. */ @NoDump @JsonIgnore public long getMicrosecsVersion() throws CalFacadeException { try { return new LastModified(getLastmod().getTimestamp()).getDate().getTime() * 1000000 + getLastmod().getSequence(); } catch (final Throwable t) { throw new CalFacadeException(t); } }
/** * ICU4J generates VTIMEZONE RRULEs with floating UNTIL, which results * in a bad VTIMEZONE because the UNTIL is converted to UTC, which will * be different depending on the default timezone of the server. So * to fix this, always add a day to UNTIL to make sure the RRULE * doesn't fall short. This should work for most timezones as timezones * don't usually change from day to day. Hopefully this is fixed in * an icu4j update. * @param vtz */ protected static void fixIcuVTimeZone(VTimeZone vtz) { for(Iterator<Observance> obIt = vtz.getObservances().iterator();obIt.hasNext();) { PropertyList<RRule> rruleList= obIt.next().getProperties(Property.RRULE); for(RRule rrule: rruleList) { Recur recur = rrule.getRecur(); if(recur.getUntil()!=null) { recur.getUntil().setTime(recur.getUntil().getTime() + ONE_DAY); } } } }
/** * ICU4J generates VTIMEZONE RRULEs with floating UNTIL, which results * in a bad VTIMEZONE because the UNTIL is converted to UTC, which will * be different depending on the default timezone of the server. So * to fix this, always add a day to UNTIL to make sure the RRULE * doesn't fall short. This should work for most timezones as timezones * don't usually change from day to day. Hopefully this is fixed in * an icu4j update. * @param vtz */ protected static void fixIcuVTimeZone(VTimeZone vtz) { for(Iterator<Observance> obIt = vtz.getObservances().iterator();obIt.hasNext();) { PropertyList<RRule> rruleList= obIt.next().getProperties(Property.RRULE); for(RRule rrule: rruleList) { Recur recur = rrule.getRecur(); if(recur.getUntil()!=null) { recur.getUntil().setTime(recur.getUntil().getTime() + ONE_DAY); } } } }
private boolean preCheckSendMail(final TeamEventDO event) { // check event ownership if (event.isOwnership() != null && event.isOwnership() == false) { return false; } // check date, send mails for future events only final Date now = new Date(); if (event.getStartDate().after(now)) { return true; } // No recurrence so event is in the past if (event.getRecurrenceRule() == null) { return false; } // Check rrule to see if an until date exists try { final RRule rRule = new RRule(event.getRecurrenceRule()); final net.fortuna.ical4j.model.Date until = rRule.getRecur().getUntil(); if (until == null) { return true; } final Date untilDate = new Date(until.getTime()); return untilDate.before(now) == false; } catch (ParseException e) { return false; } }