I wrote the following code
Date d = new Date();
CharSequence s = DateFormat.format("MMMM d, yyyy ", d.getTime());
But is asking me parameter, I want current date in string format,
like
28-Dec-2011
so that I can set over TextView
,
explain a bit, if you think something is necessary, I am new to Android Development.
You can use the
SimpleDateFormat
class 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 and here, I would suggest you go through this example and understand the concept of SimpleDateFormat class.
Final Solution:
This is the code I used:
Its simple one line code for get current Date in this yyyy-MM-dd format you can use your format that you want :
The below code displays the both time and date
This is the code i used: