Two Laptop Bag*
The moose likes Beginning Java and the fly likes String to Value and DataFormatException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "String to Value and DataFormatException" Watch "String to Value and DataFormatException" New topic

String to Value and DataFormatException

Maureen Charlton
Ranch Hand

Joined: Oct 04, 2004
Posts: 218

I have just completed two searches in the history on StringtoValue and DataFormatException. I looked at these in the API and required more information so I went to history but unfortunately it returned no results.

Could someone suggest where to look to find out more about these?

Should I be using DataFormatException instead of the Parse Exception?

Thanking you in advance.
Paul Speijers

Joined: Apr 10, 2005
Posts: 8
What situation will you be using the Exception for?
marc weber

Joined: Aug 31, 2004
Posts: 11343

Are you considering calling existing methods that might throw these exceptions? Or are you considering extending these exceptions in your own classes?

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
Maureen Charlton
Ranch Hand

Joined: Oct 04, 2004
Posts: 218
marc and Paul,

Firstly, thank you for responding to my thread.

I have actually worked out the Exception to use so I have no problems now.

However, I would still be interest on when and what these are for?

I was originally having a date format of four digits.
The date was a String (it had to be as one came in as 0181 and zero is not seen as an integer, instead it was hex as it started with zero).

I was then using the ParseException to change the string to a date format.

My correct code in the end was as follows:

Again, thank you for your help!
Paul Speijers

Joined: Apr 10, 2005
Posts: 8
I'm not sure about the DataFormatException, it's in the Zip package so I guess it has something to do with files within zipfiles having the wrong format. The ParseException however in general occurs when you try to convert a string literal to a primitive with one of the wrapper classes.
Consider Paul's rocket mass heater.
subject: String to Value and DataFormatException
Similar Threads
WA #1.....word association
Categories of History
Different Agile methodologies
Overriding and overwriting
Favourite movie chain...