D
dufffman
Hi,
I am querying a sybase database to and getting back a as a part of a
resultset a field that is stored as datetime in the database.
Once I get it out to a date object, the value of my
dateObject.toString() is
"Tue Oct 01 00:00:00 EDT 2002".
I want to convert this to yyyyMMdd (20021001) format. How do I achieve
this?
This is what I have tried
Date date = // Date object from sybase
SimpleDateFormat s = new SimpleDateFormat("yyyyMMdd");
String stringDate = date.toString();
try {
date = df.parse(stringDate);
}
catch(ParseException e) {
System.out.println("Unable to parse " + stringDate + " " +
e.getErrorOffset());
}
The above code throws the ParseException w/error offset 0. Any ideas?
Thanks,
I am querying a sybase database to and getting back a as a part of a
resultset a field that is stored as datetime in the database.
Once I get it out to a date object, the value of my
dateObject.toString() is
"Tue Oct 01 00:00:00 EDT 2002".
I want to convert this to yyyyMMdd (20021001) format. How do I achieve
this?
This is what I have tried
Date date = // Date object from sybase
SimpleDateFormat s = new SimpleDateFormat("yyyyMMdd");
String stringDate = date.toString();
try {
date = df.parse(stringDate);
}
catch(ParseException e) {
System.out.println("Unable to parse " + stringDate + " " +
e.getErrorOffset());
}
The above code throws the ParseException w/error offset 0. Any ideas?
Thanks,