Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Date object in “YYYY-MM-DD” format in android

Tags:

I have a requirement that I need to compare two Dates. One Date will come from DB which is String in "YYYY-DD-MM" firm and I need to compare this String Date with current Date.

for this I am converting Date String into Date object.

Now I need current Date also in "YYYY-MM-DD" format and it should be Date object so that I can use.compareTo() method compare two dates..

Please help me how to do that...

like image 430
brig Avatar asked Apr 25 '12 09:04

brig


People also ask

How to get Current date in dd MM yyyy format in android?

getTime(); System. out. println("Current time => " + c); SimpleDateFormat df = new SimpleDateFormat("dd-MMM-yyyy"); String formattedDate = df. format(c);

How do I get the current date in YYYY-MM-DD format?

To get today's date in (YYYY-MM-DD) format in MySQL, you can use CURDATE().


1 Answers

 Date cDate = new Date();  String fDate = new SimpleDateFormat("yyyy-MM-dd").format(cDate); 
like image 118
Zaz Gmy Avatar answered Nov 13 '22 01:11

Zaz Gmy