How can I convert currency to double in Java?

Currency restvaluta_c = object.getCurrency("var.betrag"); double valueRestvaluta_c = (double)restvaluta_c.getValue(); if (valueRestvaluta_c > 0) { valueRestvaluta_c = -valueRestvaluta_c; restvaluta_c.setValue(valueRestvaluta_c); //das geht nicht }

Does anyone know a better/working way to convert this received currency (e.g., 1000) into a negative number? A bit of Googling and ChatGPT unfortunately haven't yielded any results yet.

(1 votes)
Loading...

Similar Posts

Subscribe
Notify of
1 Answer
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
daCypher
1 year ago

With the currency class, you don’t give a value in Java, but there are only information about the respective currency. So as the currency means which symbol is used for how it is shortened etc.

Where are you trying to get the numbers? You can probably assign the value directly to a double and then hold it.