I am aware of the various posts floating out there with regards to the same issue.
Mine its a little bit different and it might be a little obvious, but I will need your comments.
I am currently using Hibernate Search and Lucene to Index entity properties.
I have a bunch of Double properties on my entities.
These entities using the default Bridges from Lucene (Bridge i.e the one in charge converting LongToString and StringToLong) are giving me troubles once the scientific notation starts to be used.
I am trying to show on DataTables on a .xhtml Credit and Debit amounts, their lenght can be as long as 18 digits, and their DataBase (DB2) type is BIGINT.
- I can not change the DataBase type
to Long for example. - I can not change either the Double
type attributes of my entities
either to for example Long
So whats the question?
Is there a way from a String say “1234567890” to retrieve a Double whose format is 1234567890 and not 1.23456789E9 as it is being done by default by Double.parseDouble(FormattedString)?
PD: I am aware of the existance of DecimalFormat, however take into account using this formater will give me a String formated correctly say : “#######.E0” but what I really need is a Double with such format, however when doing Double.parseDouble(FormattedString) I will loose such format.
Hope I was clear and thanks for any help.
Your question doesn’t really make sense. 1234567890 is the same value as 1.23456789E9 and a double represents one of them, if and only if it also represents the other.
No, there is no way to construct a
Doubleso that it is displayed in a certain way. ThetoStringmethod forDoubleis what it is, and it can’t be changed.The only thing you can do is to for instance use
DecimalFormatorString.formatbut as you’ve noted, you’ll always end up with aString.