Quote:
Originally Posted by Kuriin # Finally, input a date (a text string) in the format mm/dd/yyyy (i.e., two digits for the month, followed by a '/', followed by two digits for the day, followed by a '/', followed by four digits for the year), and output it in the common European format dd-mm-yyyy (i.e., two digits for the day, followed by a '-', followed by two digits for the month, followed by a '-', followed by four digits for the year. |
Code:
date = keyboard.nextString();
eurodate = date.substring(3, 4) + "-" + date.substring(0, 1) + "-" + date.substring(6, 9);
My java's kinda hazy, but I'm fairly sure that this will work. Substring cuts up the string you give it at the different indeces you supply it. So date.substring(3, 4) evaluates to the string "dd".