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
    • 32
    Comment on it

    In the below example code I have described, how to get Current month name , date and year from Calendar to do this I have used getInstance() method.


     

       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: