To do this, you can use a pre-written class, for example pojava http://www.pojava.org/ . It is very good to recognize different date formats and translate between them.
For example, to translate between the formats above:
try { System.out.println("Date:" + new DateTime("Date").toString("yyyy-MM-dd")); } catch (Exception error) { error.printStackTrace(); }
I find that using this class helps, since I donβt have to worry too much about the different date formats that exist there (except for the UK / USA dd / MM / yyyy and MM / dd / yyyy, which you can customize the class for)
source share