-2

Good evening everyone!

My form sends a String list in this format:

dd/ MM / yyyy

Wanted converts this string list in date to the format :

yyyy - MM - dd

How can I do this in Java ?

AmandaRJ
  • 199
  • 1
  • 10

1 Answers1

0
    Date today;
String output;
SimpleDateFormat formatter;
String pattern ="yyyy-MM-dd";
formatter = new SimpleDateFormat(pattern, currentLocale);
today = new Date();
output = formatter.format(today);
System.out.println(pattern + " " + output);

http://docs.oracle.com/javase/tutorial/i18n/format/simpleDateFormat.html

Wassim Jied
  • 27
  • 1
  • 5
  • But to do it with a List < String> ? I have a List < String> Xy , this List I will use a "For " to convert each value in Date to enter in my database. – AmandaRJ Sep 22 '16 at 22:51
  • SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); String dateInString = "your_date"; try { Date date = formatter.parse(dateInString); System.out.println(date); – Wassim Jied Sep 22 '16 at 22:59