|
Re: string to long
|
Posted: Jul 1, 2003 5:41 AM
|
|
>>In my program,users are entering in abbreviated dates like dec1995. I want to be able to convert this to a long.Is there no way,directly or indirectly I can do this?<<
It depends what you mean. The quickest and easiest solution would be:
String date = "dec1996"; long l = date.hashCode();
Whether this is appropriate largely depends on what you want to do with the long after you have created it.
As you may or may not know, java.util.Date usese a floating point number to represent the date as a number of milli-seconds since January 1st 1970. A more sophisticated approach would therefore be to parse the String into a Date and then use the getTime() function to get at this number. John
|
|