You have to use SimpleDateFormat:
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
Note That MM
stands for month and not mm
.
And you format your date and parse it as a Date
object like this:
Date dt = sf.parse(sf.format(new Date()));
Using format(new Date())
you can format a new Date()
.