Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to get Current month name,date and year in android

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 13.0k
    Comment on it

    This example shows how to get / Display the current month, date and year from calendar. To acomplish this I have used Calender.getInstance() method of Calender class. let's see the code example:

     

       protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            Calendar c = Calendar.getInstance();
            String[]monthName={"January","February","March", "April", "May", "June", "July",
                    "August", "September", "October", "November",
                    "December"};
            String month=monthName[c.get(Calendar.MONTH)];
            System.out.println("Month name:"+month);
    
            int year=c.get(Calendar.YEAR);
            int date=c.get(Calendar.DATE);
    
            textView=(TextView)findViewById(R.id.date);
            textView.setText(" "+ date+ " "+month+ " /" + "" + year);
        }

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: