Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the current system date in a string - ANDROID

Tags:

date

android

How can i get the current date in a string in Android?

I know that it's gettable using

Calendar c = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat("dd-MMM-yyyy");
String formatDate = df.format(c.getTime());

But i get it as 25-Mar-2014, and what i want is 25-3-2014. Thanks.

like image 382
Leonidas I Avatar asked Dec 03 '25 08:12

Leonidas I


1 Answers

Try this..

Change dd-MMM-yyyy to dd-MM-yyyy

SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy");
String formatDate = df.format(c.getTime());
like image 102
Hariharan Avatar answered Dec 04 '25 22:12

Hariharan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!