Android Date Month Get getLastMonth(String today)

Here you can find the source of getLastMonth(String today)

Description

get Last Month

Declaration

public static String getLastMonth(String today) 

Method Source Code

//package com.java2s;

public class Main {
    public static String getLastMonth(String today) {

        String subYear = today.substring(0, 4);
        String subMonth = today.substring(5, 7);
        String subDay = today.substring(8, 10);

        Long LongMonth = new Long(subMonth);
        long longMonth = LongMonth.longValue();

        Long LongYear = new Long(subYear);
        long longYear = LongYear.longValue();

        String tomorrow;/* www  .  ja v  a  2  s.com*/

        if (longMonth != 1) {
            longMonth--;
            if (longMonth < 10) {
                tomorrow = subYear + "-" + "0" + longMonth + "-" + subDay;
            } else
                tomorrow = subYear + "-" + longMonth + "-" + subDay;
        } else {
            longMonth = 12;
            longYear--;
            tomorrow = longYear + "-" + longMonth + "-" + subDay;
        }
        return tomorrow;
    }
}

Related

  1. getThisMonth(String today)