View Single Post
Old 09-28-2007, 09:26 PM   #36 (permalink)
Neph
Late to the party
 
Join Date: Nov 2006
Location: Maryland
Posts: 674
+0 Internets
Quote:
Originally Posted by Kuriin View Post
# 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".
Neph is offline   Reply With Quote

 
Uberguilds Network