Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

java.util.Date

Status
Not open for further replies.

dshaw21369

Programmer
Jul 8, 2002
64
How do I convert java.lang.string Date to java.util.Date using the format YYMMDD?
 
Use SimpleDateFormat
Code:
DateFormat f = new SimpleDateFormat("yymmdd");
Date d = f.parse("040227");
Greg.
 
I tried the above code yesterday and got java.text.ParseException: Unparseable date: "20040218
 
Did you set the date format to yyyymmdd? You said your date was in the format yymmdd

Greg.
 
If you create a SimpleDateFormat of the form yymmdd, you can use it to parse a string with the format yyyymmdd

Greg.
 
Sorry, I mean you can't use it to parse a yyyymmdd date.

Greg.
 
I ended up doing the following and it works:

java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyyMMdd" );
String sPaymentDueDate = INBOUND;
java.util.Date CovertDate = sdf.parse(sPaymentDueDate);
outboundsets(CovertDate);

Thanks for all your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top