Example usage for org.joda.time LocalTime now

List of usage examples for org.joda.time LocalTime now

Introduction

In this page you can find the example usage for org.joda.time LocalTime now.

Prototype

public static LocalTime now(Chronology chronology) 

Source Link

Document

Obtains a LocalTime set to the current system millisecond time using the specified chronology.

Usage

From source file:com.karthikb351.vitinfo2.fragment.schedule.ScheduleListAdapter.java

License:Open Source License

private void compareTimeAndUpdate(ScheduleView scheduleView, String startTime, String endTime) {

    // Formatting strings to get the nearest hours
    startTime = formatTime(startTime);/*  w  w w.  j a  v  a 2 s  .co m*/
    endTime = formatTime(endTime);

    // Comparing time
    LocalTime nowTime = LocalTime.now(DateTimeZone.UTC);
    LocalTime floorTime = new LocalTime(startTime);
    LocalTime ceilTime = new LocalTime(endTime);

    // To correct the timezone difference
    nowTime = nowTime.plusHours(5);
    nowTime = nowTime.plusMinutes(30);

    boolean lowerCheck = nowTime.isAfter(floorTime) || nowTime.isEqual(floorTime);
    boolean upperCheck = nowTime.isBefore(ceilTime);
    boolean upperOverCheck = nowTime.isAfter(ceilTime) || nowTime.isEqual(ceilTime);

    if (lowerCheck && upperCheck) {
        scheduleView.setState(TimeLineView.STATE_CURRENT);
    } else if (lowerCheck && upperOverCheck) {
        scheduleView.setState(TimeLineView.STATE_FINISHED);
    } else {
        scheduleView.setState(TimeLineView.STATE_SCHEDULED);
    }
}

From source file:de.appsolve.padelcampus.data.TimeSlot.java

public boolean getPast() {
    LocalDate today = LocalDate.now(Constants.DEFAULT_TIMEZONE);
    LocalTime now = LocalTime.now(Constants.DEFAULT_TIMEZONE);
    return getDate().isBefore(today) || (getDate().equals(today) && getStartTime().isBefore(now));
}