What is the best data type to use in greendao for Decimal(10,2)

60 views Asked by At

I am trying to migrate my old db written in sqlite to greendao ORM , I need to set the column to DECIMAL(10,2) for storing the price of the item. What is the equivalent data type that I can use. DO I need to use a custom data type for that?

1

There are 1 answers

0
Markus Junginger On

There are a couple of options, use a long value representing the smaller unit.

Then if you had a long price property, you could get the big unit using price / 100 and the small unit via price % 100. Like this you can still use price for regular integer calculation.

For formatting, don't forget an extra '0' for the small unit if it is single digit.