Android Day Add decrementOneDay(Time t)

Here you can find the source of decrementOneDay(Time t)

Description

decrement One Day

License

Apache License

Declaration

private static final void decrementOneDay(Time t) 

Method Source Code

//package com.java2s;
/*//from   ww w.jav a 2 s  .  c  om
 * Copyright (C) 2011 The original author or authors.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */

import android.text.format.Time;

public class Main {
    private static final void decrementOneDay(Time t) {
        if (t.monthDay > 1) {
            t.monthDay--;
            return;
        }

        if (t.month > 0) {
            t.month--;

        } else {
            t.year--;
            t.month = 11;
        }

        // Set day to end of month
        t.monthDay = 1; // temporary, have a valid date
        t.monthDay = t.getActualMaximum(Time.MONTH_DAY);
    }
}

Related

  1. addDayOfMonth(Date date)
  2. addDayOfMonth(Date date, int difference)
  3. addDay(long dateTimeMillis)
  4. addDay(long dateTimeMillis)
  5. beforeNDays(Calendar c, int n)
  6. addDays(Date date, int days)