Hi, I have a text field, and my users will be typing a date in the format "dd-MM-yyyy" and I can check this. How can I construct a java.util.Date from this ? Will I have to extract each integer and calculate the appropriate number in milliseconds ? Has anyone done this ? I'm a bit wary of the whole Date thing cos all the useful easy methods seem to be deprecated ! (actually, I'm feeling a bit depreKated at the moment too) Cheers, Kate
Chad McGowan
Ranch Hand
Joined: May 10, 2001
Posts: 265
posted
0
Kate, I think this example should help. import java.text.*; import java.util.Date; public class DateTest { public static void main(String[] args) { SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); try { Date d = sdf.parse("02-05-1999"); System.out.println(d); } catch (ParseException e) { System.out.println("whoops"); } } }
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.