Thanks for the reply.. I guess I didn't explain this very well..
my 2 SimpleDateFormats are being read from the DB.
String datepattern = "yyyy-MM-dd";
SimpleDateFormat data_date = new SimpleDateFormat(datepattern);
data_date.applyPattern(string_date);
String timepattern = "HH:mm:ss";
SimpleDateFormat data_time = new SimpleDateFormat(timepattern);
data_time.applyPattern(string_time);
Basically I have 2 different choices the way I see it.
1.) Tokenize the string_date and string_time and create the Calendar.
2.) Somehow convert SimpleDateFormats to ints and create the Calendar.
Thanks in advance!
Sonny
OK, you get two values out of a database.
One is a date value in "yyyy-MM-dd" format, for example "2004-08-21"
One is a time value in "HH:mm:ss" format, for example "22:12:30".
That's what I understand from your description, but tell me if this is
incorrect.
I'm not sure what you are trying to accomplish next.
Do you want these two values together to represent one date&time value?
In that case I would create a combined SimpleDateFormat, like this:
------------------------------
String combinedPattern = "yyyy-MM-dd HH:mm:ss";
SimpleDateFormat datetimeParser = new SimpleDateFormat(combinedPattern);
String string_date = ... retrieved from DB;
String string_time = ... retrieved from DB;
String string_datetime = string_date + " " + string_time;
java.util.Date dateAndTime = null;
try {
dateAndTime = datetimeParser.parse(string_datetime);
} catch (java.text.ParseException ex) {
ex.printStackTrace();
}
------------------------------
Now, you can use the java.util.Date instance 'dateAndTime' for the
things you want to do, e.g.
------------------------------
System.out.println(dateAndTime);
Calendar calendar = Calendar.getInstance();
calendar.setTime(dateAndTime);
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
------------------------------
HTH,
--
Regards,
Roland de Ruiter
___ ___
/__/ w_/ /__/
/ \ /_/ / \