I have to display the date in dd-mm-yy format as per the UI design for our Android app. can any one help me, how to achieve it?
Answer
Use SimpleDateFormat
:
http://developer.android.com/reference/java/text/SimpleDateFormat.html
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yy");
Log.i("DATE", sdf.format(new Date()));
You should store your instance of sdf, if you are planning to be formatting your dates repeatedly. Outside a loop, or as a class member variable, for example.
No comments:
Post a Comment