Menu

Display ics file content as a list sort by date

kinglite
2014-11-20
2014-11-22
  • kinglite

    kinglite - 2014-11-20

    Hi there,

    right now I'm stuck with ical4j and I recently foud out about biweekly.
    I try to display the content of a ics file in a list sorted by the start date for my android app.
    The problem now is that the content isn't completely sorted by date.
    here the link to the file: https://stundenplan.hs-furtwangen.de/splan/ical?type=pg&puid=8&pgid=2505&lan=de

    If I read the content and print it out it comes in the order from the file.
    But it should look like this:

    Monday: Date
    -Event 1: Time Location
    -Event 2: Time Location

    Tuesday: Date
    - ....

    is there an easier way than to iterate through all the events over and over again and sort them until its sorted? Some methods or so?

     
  • Michael Angstadt

    Sorry, biweekly doesn't provide any such functionality. However, it might help to sort the list of VEVENTs by DTSTART:

    :::java
    ICalendar ical = ...
    List<VEvent> events = new ArrayList<VEvent>(ical.getEvents());
    Collections.sort(events, new Comparator<VEvent>(){
      public int compare(VEvent event1, VEvent event2) {
         return event1.getDateStart().getValue().compareTo(event2.getDateStart().getValue());
      }
    });
    
     

Anonymous
Anonymous

Add attachments
Cancel