05-14-2009 04:06 PM
Hopefully, I'm asking better questions now. Don't feel like a *total* newbite these days...
But this one if baffling me...
According to everything I've read, I should be able to use the HttpDateParser class in
net.rim.device.api.io.http.HttpDateParser to send a string and get back a date (long).
In the documentation for the class it says:
public static long parse(String date)
However, when I try to compile this line:
HttpDateParser httpdateparser = new HttpDateParser();
I get this error message:
HttpDateParser() has private access in net.rim.device.api.io.http.HttpDateParser
WTF? Am I wrong or is there a difference between the 'public' assignation in the doc and the 'private' in the error message?
Thanks in advance!
-- John Kiernan
05-14-2009 04:27 PM - edited 05-14-2009 04:28 PM
This class does not have public constructor.
And parse(String) method is static.
Call this method as follows
long parsedDate = HttpDateParser.parse(string2Parse);
05-14-2009 04:30 PM
static class methods and class fields do not require to build class instance to invoke/access them.
Moreover even it is possible it is encouraged to access static methods/fields via class reference rather than class instance reference.
05-14-2009 04:53 PM
Thanks for everyone's help. As it turned out, I didn't really have all of the data necessary to dso this conversion (I could have fudged it, I suppose), but here's what I ended up doing (it involved a Calendar object):
public static DateFormat myDF = new SimpleDateFormat("MM/dd/yy");
String workstring = singlerecord._Workdate;
String monthstr = workstring.substring(0,2);
String daystr = workstring.substring(3,5);
String yearstr = workstring.substring(8,10);
int monthnum = Integer.parseInt(monthstr);
int daynum = Integer.parseInt(daystr);
int yearnum = Integer.parseInt(yearstr);
Calendar getCal = Calendar.getInstance();
getCal.set (Calendar.MONTH,monthnum );
Date thedate = getCal.getTime();
long workdate = thedate.getTime();
MyDateField wdfield = new MyDateField("", workdate, myDF, DrawStyle.LEFT, 1, rowcount);
Thanks for everyone's help!