org.joda.time.DateTimeComparator Java Examples

The following examples show how to use org.joda.time.DateTimeComparator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RepairRun.java    From cassandra-reaper with Apache License 2.0 5 votes vote down vote up
/**
 * Order RepairRun instances by time. Primarily endTime, secondarily startTime. Descending, i.e. latest first.
 *
 * @param other the RepairRun compared to
 * @return negative if this RepairRun is later than the specified RepairRun. Positive if earlier. 0 if equal.
 */
@Override
public int compareTo(RepairRun other) {
  DateTimeComparator comparator = DateTimeComparator.getInstance();
  int endTimeComparison = comparator.compare(endTime, other.endTime);
  if (endTimeComparison != 0) {
    return -endTimeComparison;
  } else {
    return -comparator.compare(startTime, other.startTime);
  }
}
 
Example #2
Source File: HoraireFragment.java    From ETSMobile-Android2 with Apache License 2.0 5 votes vote down vote up
public void fillListView(){

        try {
            List<Seances> seances = databaseHelper.getDao(Seances.class).queryForAll();
            List<Event> events = databaseHelper.getDao(Event.class).queryForAll();
            allseanceAdapter.setItemList(seances, events);


            List<Seances> upcomingSeances = new ArrayList<>();
            List<Event> upcomingEvents = new ArrayList<>();

            DateTime now = new DateTime();
            for(Seances sc : seances){
                DateTime scDate = DateTime.parse(sc.getDateDebut());
                if( DateTimeComparator.getDateOnlyInstance().compare(now, scDate) <= 0 ){
                    upcomingSeances.add(sc);
                }
            }
            for(Event ev : events){
                DateTime evDate = DateTime.parse(ev.getDateDebut());
                if( DateTimeComparator.getDateOnlyInstance().compare(now, evDate) <= 0 ){
                    upcomingEvents.add(ev);
                }
            }

            upcomingseanceAdapter.setItemList(upcomingSeances,upcomingEvents);

        } catch (SQLException e) {
            e.printStackTrace();
        }

        allseanceAdapter.notifyDataSetChanged();
        upcomingseanceAdapter.notifyDataSetChanged();
    }
 
Example #3
Source File: EventSummary.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
private boolean isToday(long dateMs) {
	TimeZone timeZone = getCurrentUserTimezone();
	DateTime thisDate = new DateTime(dateMs).withZone(DateTimeZone.forTimeZone(timeZone));
	//Start of day at this local
	DateTime today = new DateTime().withTime(0, 0, 0, 0).withZone(DateTimeZone.forTimeZone(timeZone));
	DateTimeComparator dtComp = DateTimeComparator.getDateOnlyInstance();
	return  (dtComp.compare(thisDate, today) == 0);
	
}
 
Example #4
Source File: EventSummary.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
private boolean isToday(long dateMs) {
	TimeZone timeZone = getCurrentUserTimezone();
	DateTime thisDate = new DateTime(dateMs).withZone(DateTimeZone.forTimeZone(timeZone));
	//Start of day at this local
	DateTime today = new DateTime().withTime(0, 0, 0, 0).withZone(DateTimeZone.forTimeZone(timeZone));
	DateTimeComparator dtComp = DateTimeComparator.getDateOnlyInstance();
	return  (dtComp.compare(thisDate, today) == 0);
	
}