I don't know of any elegant way to do this what I would do is,
1. parse the date String into its constituent parts
2. create ints from the parts
3. create an instance of java.util.Calendar
4. set the Calendar time with the ints
5. get the long value of the date and use that when you create the instance of the java.util.Date
try {
int theYear = java.lang.Integer.parseInt(dateStr.substring(0,4));
int theMonth = (java.lang.Integer.parseInt(dateStr.substring(4,6))) - 1; // subtract one month because month 0 is January
int theDay = java.lang.Integer.parseInt(dateStr.substring(6,8));
java.util.Calendar theCalendar = java.util.Calendar.getInstance();
theCalendar.set(theYear, theMonth, theDay);
java.util.Date theDate = theCalendar.getTime();
}
You could avoid using the java.util.Calendar class and just calculate the long value of the date when you get the int values of the year, month and day.
Julio Lopez
M-Group Systems
[This message has been edited by Julio Lopez (edited July 13, 2001).]