Android Time Class

Get Old Month Using Time Class

// Author: Mahbub


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) {

    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

Final, Finally (Part 2: Final Class)

welcome to part 2 of Final Keyword. Lets Start …

Final Class

We can declare a class as final. After that we cant create child class under that final class.

example time.

public final class King {
    public static void main (String args []){
        System.out.println("king Arthur");   

public class Test extends King {

// compile error: cannot inherit from final King

so why on earth you want a final class,

1. Final classes (Immutable) are read-only.
2. Thread safe, no synchronization overhead.

a very good explanation

Enjoy 🙂


A class defines Characteristics of an object at design time. It is a blueprint of an object.

• Fields or Properties or variables
• Operations or Methods or functions
For example properties of a car class are
• Color
• Number of doors
• Model
Methods of a car class are
• on()
• off()
• turn()

public class Car{

    public String color;
    public int numberOfDoors;    // these are the properties
    public int model;

    public void on(){

    public void off(){          // these are the methods

    public void turn(){

Naming Convention For Class

Class names should be nouns, in mixed case with the first letter of each internal word capitalized.

For example

JavaMahbub, HabaMahbub, Mahbub  etc


Naming Convention For Properties

Internal words start with capital letters. Variable names should not start with underscore _ or dollar sign $ characters, even though both are allowed.

For example

int i, int j, String kiHolo etc


Naming Convention For Methods

Methods should be verbs, in mixed case with the first letter lowercase, with the first letter of each internal word capitalized.

For example

go(), jojo(), goJojo() etc



Want to know more ?

CamelCase (camel case or camel-case), also known as medial capitals, is the practice of writing compound words or phrases in which the elements are joined without spaces, with each element’s initial letter capitalized within the compound and the first letter either upper or lower case—as in “LaBelle”, BackColor, “McDonald’s”, or “iPod”. The name comes from the uppercase “bumps” in the middle of the compound word, suggestive of the humps of a camel. The practice is known by many other names.

Original Post