File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes java.util.Date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java.util.Date" Watch "java.util.Date" New topic
Author

java.util.Date

kate damond
Ranch Hand

Joined: Apr 17, 2001
Posts: 77
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
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://aspose.com/file-tools
 
subject: java.util.Date
 
Similar Threads
Conversion of Timestamp to Date format Urgent
server date
Taking a getDate from an Array and
Pass by ref- pgm err
how can i get yesterdays date?