0

Is there a way to format this:

CriteriaQuery<Country> q = cb.createQuery(Country.class);
  Root<Country> c = q.from(Country.class);
  q.select(c.get("currency")).distinct(true);

So when all the NUMERIC currency elements are returned they look like:

12345 -> $12,345.00

123,45 -> $123.45

This way I don't hace to loop the resultset formating strings.

AFP_555
  • 2,392
  • 4
  • 25
  • 45

1 Answers1

0

Here's the answer:

https://stackoverflow.com/a/40008789/2545722

Just needed to use the CriteriaBuilder's function method, which allows developers to call SQL functions. I don't like it because this code should change if the DB is changed.

Community
  • 1
  • 1
AFP_555
  • 2,392
  • 4
  • 25
  • 45