Package net.fortuna.ical4j.model

Examples of net.fortuna.ical4j.model.Date


        return dt;
    }

    public static Date toDate(String dateStr) {
        GregorianCalendar cal = toSGTCalendar(dateStr, null);
        Date dt = new Date(cal.getTime());
        return dt;
    }
View Full Code Here


        pl.add(new Summary(course.getCourseName() + " " + ct.getClassType()
                + " " + ct.getRemark()));
        String[] split = ct.getSemesterTimetable().getStartExam().split("-");
        String str = split[0] + split[1] + split[2];
        try {
            pl.add(new RRule(new Recur(Recur.WEEKLY, new Date(str))));
        } catch (ParseException ex) {
            Logger.getLogger(ClassVEvent.class).error("Error when parsing "
                    + "recurrence rule for " + course.getCourseName()
                    + " class timetable", ex);
        }
View Full Code Here

                vevent.getProperties().add(new DtStart(new DateTime(event.getStartDate())));
                vevent.getProperties().add(new DtEnd(new DateTime(event.getEndDate().getTime())));
            }
            else
            {
                vevent.getProperties().add(new DtStart(new Date(event.getStartDate())));
                vevent.getProperties().getProperty(Property.DTSTART).getParameters().add(Value.DATE);
                vevent.getProperties().add(new DtEnd(new Date(event.getEndDate().getTime())));
                vevent.getProperties().getProperty(Property.DTEND).getParameters().add(Value.DATE);
            }
           
            if(event.isOccupied())
                vevent.getProperties().add(new Transp("OPAQUE"));
View Full Code Here

                    event.setTitle("XXX");
                if(comp.getProperties().getProperty((Property.DTSTART)) != null)
                    if(comp.getProperties().getProperty(Property.DTSTART).getParameter("VALUE") != null
                       && comp.getProperties().getProperty(Property.DTSTART).getParameter("VALUE").getValue().equals("DATE"))
                    {
                        event.setStartDate(new Date(comp.getProperties().getProperty(Property.DTSTART).getValue()));
                        event.setAllDay(true);
                    }    
                    else
                        event.setStartDate(new DateTime(comp.getProperties().getProperty(Property.DTSTART).getValue()));
                if(comp.getProperties().getProperty((Property.DTEND)) != null)
                    if(comp.getProperties().getProperty(Property.DTEND).getParameter("VALUE") != null
                            && comp.getProperties().getProperty(Property.DTEND).getParameter("VALUE").getValue().equals("DATE"))
                         {
                             event.setEndDate(new Date(comp.getProperties().getProperty(Property.DTEND).getValue()));
                         }    
                         else
                             event.setEndDate(new DateTime(comp.getProperties().getProperty(Property.DTEND).getValue()));
                else
                    event.setEndDate(event.getStartDate());
View Full Code Here

       
        if(event.getRecurrenceCycle() != null)
            recur.setInterval(event.getRecurrenceCycle());
       
        if(event.getRecurrenceType() == RecurrenceType.UNTIL_DATE)
            recur.setUntil(new Date(event.getRecurrenceEndDate()));
        else if(event.getRecurrenceType() == RecurrenceType.NUMBER_OF_TIMES)
            recur.setCount(event.getRecurrenceNumberOfTimes());
       
        for(RecurrenceInWeek day : event.getRecurrenceInWeek())
        {
View Full Code Here

        return obj;

    }

    private static VEvent convertEventBean(EventBean event) {
        Date begin;
        Date end;
        if (event.isAllDay()) {
            begin = new Date(event.getBegin().toCalendar(new Locale("pt")).getTime());
            end = new Date(event.getEnd().toCalendar(new Locale("pt")).getTime());
        } else {
            begin = new DateTime(event.getBegin().toCalendar(new Locale("pt")).getTime());
            end = new DateTime(event.getEnd().toCalendar(new Locale("pt")).getTime());
        }
        VEvent vEvent = new VEvent(begin, end, event.getTitle());

        vEvent.getStartDate().setTimeZone(TIMEZONE);
        vEvent.getEndDate().setTimeZone(TIMEZONE);

        if (event.getLocation() != null) {
            vEvent.getProperties().add(new Location(event.getLocation()));
        }

        if (event.getUrl() != null) {
            try {
                vEvent.getProperties().add(new Url(new URI(event.getUrl())));
            } catch (URISyntaxException e) {
            }
        }

        if (event.getNote() != null) {
            vEvent.getProperties().add(new Description(event.getNote()));
        }

        Uid uid = new Uid(digest(event.getTitle() + "-" + begin.toGMTString() + "-" + end.toGMTString()));
        vEvent.getProperties().add(uid);

        return vEvent;
    }
View Full Code Here

        return getNextRecurringDate(recur, seedDate, startDate);
    }

    private static LocalDate getNextRecurringDate(final Recur recur, final LocalDate seedDate, final LocalDate startDate) {
        final DateTime periodStart = new DateTime(startDate.toDate());
        final Date seed = convertToiCal4JCompatibleDate(seedDate);
        final Date nextRecDate = recur.getNextDate(seed, periodStart);
        return nextRecDate == null ? null : new LocalDate(nextRecDate);
    }
View Full Code Here

        return nextRecDate == null ? null : new LocalDate(nextRecDate);
    }

    private static Date convertToiCal4JCompatibleDate(final LocalDate inputDate) {
        // Date format in iCal4J is hard coded
        Date formattedDate = null;
        final DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        final String seedDateStr = df.format(inputDate.toDateTimeAtStartOfDay().toDate());
        try {
            formattedDate = new Date(seedDateStr, "yyyy-MM-dd");
        } catch (final ParseException e) {
            e.printStackTrace();
        }
        return formattedDate;
    }
View Full Code Here

    }

    private static Collection<LocalDate> getRecurringDates(final Recur recur, final LocalDate seedDate, final LocalDate periodStartDate,
            final LocalDate periodEndDate, final int maxCount) {
        if (recur == null) { return null; }
        final Date seed = convertToiCal4JCompatibleDate(seedDate);
        final DateTime periodStart = new DateTime(periodStartDate.toDate());
        final DateTime periodEnd = new DateTime(periodEndDate.toDate());

        final Value value = new Value(Value.DATE.getValue());
        final DateList recurringDates = recur.getDates(seed, periodStart, periodEnd, value, maxCount);
View Full Code Here

        final Collection<LocalDate> recurringDates = new ArrayList<>();

        for (@SuppressWarnings("rawtypes")
        final Iterator iterator = dates.iterator(); iterator.hasNext();) {
            final Date date = (Date) iterator.next();
            recurringDates.add(new LocalDate(date));
        }

        return recurringDates;
    }
View Full Code Here

TOP

Related Classes of net.fortuna.ical4j.model.Date

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.