• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem in Converting String to Date Object

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
my name is arif i am converting String to date object while converting this i am getting Run time Exception can any one advise how can i resolve this problem
here in this code i am using String tokennizer reading a data from a text file
here is my code

this is the Exception which i am getting

this is the method i am calling to convert String to date object




here is an text file which i am reading

priya Rao DBA 13-APR-60 02-JUN-92 Mahdipatnam Hyderabad 01-FEB-93 - Admin F priya M 7842236802 12348
Arif Rizwan Development 14-FEB-88 12-MAR-12 Sathya coloney Hyderabad 10-FEB-14 - Software Engineer M asdfgh Manager 7842655502 123
AFif Rizwan Development 14-FEB-88 12-MAR-12 Sathya coloney Hyderabad 10-FEB-14 - Software Engineer M asdfgh Manager 7802655502 123
Asif Rizwan Development 14-FEB-88 12-MAR-12 Sathya coloney Hyderabad 10-FEB-14 - Software Engineer M asdfgh Manager 7842631102 123
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Arif, we will need more details. What does the string you are trying to convert look like? What does the ValidateUtils.convertToDate() method look like? Apparently (from the exception) the String contains an M in it and the method is using a number formatter which does not expect an M. So you will either have to fix the String, the parsing, or the formatter. But beyond that we don't have enough information.
 
Saloon Keeper
Posts: 15510
363
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually, the exception says the problem is in convertToLong(). This doesn't seem date related at all.
 
Steve Luke
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Arif Rizwan wrote:here is an text file which i am reading

priya Rao DBA 13-APR-60 02-JUN-92 Mahdipatnam Hyderabad 01-FEB-93 - Admin F priya M 7842236802 12348
Arif Rizwan Development 14-FEB-88 12-MAR-12 Sathya coloney Hyderabad 10-FEB-14 - Software Engineer M asdfgh Manager 7842655502 123
AFif Rizwan Development 14-FEB-88 12-MAR-12 Sathya coloney Hyderabad 10-FEB-14 - Software Engineer M asdfgh Manager 7802655502 123
Asif Rizwan Development 14-FEB-88 12-MAR-12 Sathya coloney Hyderabad 10-FEB-14 - Software Engineer M asdfgh Manager 7842631102 123


Hi Arif,

Stephen is right, you are looking at the wrong method, the error tells you the problem is in the convertToLong. Also, it is usually considered poor etiquette to edit your post after someone made a response, it is better to post a response with the new information requested. Finally, posting the entire file isn't going to help. You need to find the actual strings that are being sent to the convertToLong method which causes the problem. Then when you under stand what the input is you can understand where it comes from.
 
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem is in the parsing of the designation field (line 30 in your code). It only reads in one token which is fine for the first line where the designation is Admin, but not for the second line where the designation is Software Engineer.
The code that reads the designation will only read 'Software', line 31 will then read 'Engineer' as the gender, line 32 will read 'M' as the password, line 33 will read 'asdfgh' as the Role and line 34 will try to read 'Manager. as the MobNo, but 'Manager' is not a number so you get the exception.
reply
    Bookmark Topic Watch Topic
  • New Topic