Last active
December 26, 2015 10:48
-
-
Save lifeparticle/7139069 to your computer and use it in GitHub Desktop.
Android Time Class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Author: Mahbub | |
// http://mahbubzaman.wordpress.com/2013/10/24/android-time-class/ | |
/* | |
http://developer.android.com/reference/android/text/format/Time.html | |
just provide the month, year and day and get previous dates | |
Since Time class does not provides months and day name, you have to do that by yourself | |
*/ | |
public void oldDate(int month, int year, int day) { | |
--month; | |
oldDay = 1; // here i did not vary the old months date | |
String s; | |
for (int i = 1; i <= 5; ++i) { // i am fetching last 5 month data | |
if (month == -1) { | |
month = 11; | |
year = year - 1; | |
} | |
oldYear = year; | |
oldMonth = month; | |
Time old = new Time(); | |
old.set(oldDay, oldMonth, oldYear); | |
s = "Month of "+old.month+ +old.year; | |
// update | |
--month; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment