Example usage for android.text.format Time switchTimezone

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

Introduction

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

Prototype

public void switchTimezone(String timezone) 

Source Link

Document

Convert this time object so the time represented remains the same, but is instead located in a different timezone.

Usage

From source file:eu.inmite.apps.smsjizdenka.adapter.TicketsAdapter.java

/**
 * Gets validity of ticket with time {@code t} in minutes.
 *//*from w  w w  .  j ava  2  s. c  o  m*/
public static int getValidityMinutes(Time t) {
    if (t == null) {
        return -1;
    }

    final Time now = new Time();
    now.setToNow();
    now.switchTimezone(Time.getCurrentTimezone());
    return (int) Math.ceil((t.toMillis(true) - now.toMillis(true)) / 1000d / 60d);
}

From source file:org.privatenotes.Note.java

public void setLastChangeDate(Time lastChangeDate) {
    this.lastChangeDate = lastChangeDate;
    lastChangeDate.switchTimezone(Time.TIMEZONE_UTC);
}

From source file:Event.java

private Time getRecurrenceEnd() {
    Time until = new Time();
    //Calendar calendar = new GregorianCalendar();
    //calendar.setTime(recurrenceEnd);
    //int monthDay = calendar.get(Calendar.DAY_OF_MONTH);
    //int month = calendar.get(Calendar.MONTH);
    //int year = calendar.get(Calendar.YEAR);
    //calendar.setTime(endDate);
    //int second = calendar.get(Calendar.SECOND);
    //int minute = calendar.get(Calendar.MINUTE);
    //int hour = calendar.get(Calendar.HOUR);
    //until.set(second, minute, hour, monthDay, month, year);
    //until.second++;
    //until.normalize(false);
    until.set(recurrenceEnd.getTime());//from   w  ww. ja va2s . co m
    until.switchTimezone(Time.TIMEZONE_UTC);
    return until;
}