Search in sources :

Example 46 with DateTime

use of net.fortuna.ical4j.model.DateTime in project zm-mailbox by Zimbra.

the class SchedulingViewOfTnef method getDueDate.

/**
 * @return the time in UTC that the meeting object was sent or null
 * @throws IOException
 */
public DateTime getDueDate() throws IOException {
    DateTime timeVal = null;
    if (this.getIcalType() != ICALENDAR_TYPE.VTODO) {
        return null;
    }
    timeVal = MapiPropertyId.PidLidTaskDueDate.getDateTimeAsUTC(this);
    return timeVal;
}
Also used : DateTime(net.fortuna.ical4j.model.DateTime)

Example 47 with DateTime

use of net.fortuna.ical4j.model.DateTime in project zm-mailbox by Zimbra.

the class MapiPropertyId method getDateTimeAsUTC.

/**
 * PT_SYSTIME properties wrap FILETIME which is a count of seconds since start of 1601
 * Note that some PT_SYSTIME properties are actually stored such that if they are treated
 * as UTC times, the day/month/year/hour/min etc components are correct in localtime.
 * Calling this method for such properties will result in a DateTime which doesn't reflect
 * the underlying real date and time on its own - but this can still be useful.
 * @param schedView
 * @return DateTime object equivalent to a PT_SYSTIME property where that property
 *         represents a time in UTC
 * @throws IOException
 */
public DateTime getDateTimeAsUTC(SchedulingViewOfTnef schedView) throws IOException {
    Date javaDate = getDateValue(schedView);
    if (javaDate == null) {
        return null;
    }
    DateTime icalDateTime = new net.fortuna.ical4j.model.DateTime(javaDate);
    icalDateTime.setUtc(true);
    return icalDateTime;
}
Also used : Date(java.util.Date) DateTime(net.fortuna.ical4j.model.DateTime)

Example 48 with DateTime

use of net.fortuna.ical4j.model.DateTime in project zm-mailbox by Zimbra.

the class TZRule method getDtStart.

/**
 *   From initial TNEF to iCalendar Spec.
 *       The DTSTART property can be hard-coded to 16010101T000000. This is a value that
 *       works well across many calendar client apps.
 *   Note: Some examples seen are similar to this but include the hour of the transition.
 *         Suspect that is useful - so including it.
 *   Zimbra replaces our timezones with closest matchin known ones, so not worth trying
 *   to improve this to see if can choose an accurate start date/time in 1601.
 *
 * @param hr
 * @param min
 * @return
 */
private DtStart getDtStart(int hr, int min) {
    TimeZone utcZone = TimeZone.getTimeZone("UTC");
    GregorianCalendar gc = new GregorianCalendar(1601, 0, /* zero based */
    1, hr, min);
    gc.setTimeZone(utcZone);
    Date startDate = gc.getTime();
    DateTime startDateTime = new DateTime(startDate);
    return new DtStart(startDateTime);
}
Also used : TimeZone(java.util.TimeZone) DtStart(net.fortuna.ical4j.model.property.DtStart) GregorianCalendar(java.util.GregorianCalendar) Date(java.util.Date) DateTime(net.fortuna.ical4j.model.DateTime)

Example 49 with DateTime

use of net.fortuna.ical4j.model.DateTime in project zm-mailbox by Zimbra.

the class IcalUtil method icalUtcTime.

/**
 * Use when a UTC equivalent of a DateTime is required with the trailing Z indicating
 * that it is UTC
 * @param localTimeSince1601
 * @param tzDef
 * @return
 */
public static String icalUtcTime(long localTimeSince1601, TimeZoneDefinition tzDef) {
    DateTime localTime = IcalUtil.localMinsSince1601toDate(localTimeSince1601, tzDef);
    SimpleDateFormat utcTimeFmt = new SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'");
    java.util.TimeZone utcTZ = TimeZone.getTimeZone(TimeZones.UTC_ID);
    utcTimeFmt.setTimeZone(utcTZ);
    return utcTimeFmt.format(localTime);
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) DateTime(net.fortuna.ical4j.model.DateTime)

Example 50 with DateTime

use of net.fortuna.ical4j.model.DateTime in project zm-mailbox by Zimbra.

the class IcalUtil method friendlyLocalTime.

/**
 * Intended for diagnostic purposes.
 * @param localTimeSince1601 is the number of minutes since the start of 1601 in <code>tzDef</code>
 * @param tzDef
 * @return
 */
public static String friendlyLocalTime(long localTimeSince1601, TimeZoneDefinition tzDef) {
    DateTime localTime = IcalUtil.localMinsSince1601toDate(localTimeSince1601, tzDef);
    SimpleDateFormat localTimeFmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
    java.util.TimeZone tz;
    if (tzDef == null) {
        tz = TimeZone.getTimeZone(TimeZones.UTC_ID);
    } else {
        tz = tzDef.getTimeZone();
    }
    localTimeFmt.setTimeZone(tz);
    return localTimeFmt.format(localTime);
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) DateTime(net.fortuna.ical4j.model.DateTime)

Aggregations

DateTime (net.fortuna.ical4j.model.DateTime)70 Period (net.fortuna.ical4j.model.Period)20 VEvent (net.fortuna.ical4j.model.component.VEvent)18 BwDateTime (org.bedework.calfacade.BwDateTime)15 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)15 Date (java.util.Date)13 TimeZone (net.fortuna.ical4j.model.TimeZone)13 ParseException (java.text.ParseException)12 DtStart (net.fortuna.ical4j.model.property.DtStart)11 Date (net.fortuna.ical4j.model.Date)10 Dur (net.fortuna.ical4j.model.Dur)10 PeriodList (net.fortuna.ical4j.model.PeriodList)10 PropertyList (net.fortuna.ical4j.model.PropertyList)9 DtStamp (net.fortuna.ical4j.model.property.DtStamp)9 LastModified (net.fortuna.ical4j.model.property.LastModified)9 Uid (net.fortuna.ical4j.model.property.Uid)9 Calendar (net.fortuna.ical4j.model.Calendar)8 Recur (net.fortuna.ical4j.model.Recur)8 ExDate (net.fortuna.ical4j.model.property.ExDate)8 GregorianCalendar (java.util.GregorianCalendar)7