I wrote the following code
Date d = new Date();
CharSequence s = DateFormat.format("MMMM d, yyyy ", d.getTime());
I want the current date in string format, like
28-Dec-2011
so that I can set it into a TextView.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use the
SimpleDateFormatclass for formatting date in your desired format.Just check this link where you get an idea for your example.
For example:
Update:
The detailed example is here, I would suggest you go through this example and understand the concept of SimpleDateFormat class.
Final Solution: