Example usage for android.text.format Time toString

List of usage examples for android.text.format Time toString

Introduction

In this page you can find the example usage for android.text.format Time toString.

Prototype

@Override
public String toString() 

Source Link

Document

Return the current time in YYYYMMDDTHHMMSS<tz> format

Usage

From source file:org.cinedroid.tasks.impl.RetrievePerformancesTask.java

/**
 * Removes any times which have passed from the list
 * /*from   ww  w . j a v a 2s  .c  o  m*/
 * @param results
 */
private void filterPastDates(final FilmDate filmDate) {
    Time currentTime = new Time();
    currentTime.setToNow();

    Time performanceDate = new Time();
    String date = filmDate.getDate();
    performanceDate.parse(date);

    // Check if the performance date is before the current time. This will only be true in the situation that the filmDate represents
    // the current day, as the cineworld api does not return dates which have passed. If the object is the current date, the film
    // performances need filtering.
    if (currentTime.after(performanceDate)) {
        for (Iterator<FilmPerformance> i = filmDate.getPerformances().iterator(); i.hasNext();) {
            String time = i.next().getTime().replace(":", ""); // Get the time with the : removed.
            performanceDate.parse(String.format("%sT%s00", date, time));
            Log.d(TAG, String.format("Checking %s", performanceDate.format("%d %b %H:%M")));
            if (currentTime.after(performanceDate)) {
                Log.d(TAG, String.format("Removed %s", performanceDate.format("%d %b %H:%M")));
                i.remove();
            }
        }
    }
    Log.d(TAG, String.format("Current Time %s", currentTime.toString()));
}