• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java equivalent of NUMERIC(2,2)  RSS feed

 
Kristofer Hindersson
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the java-representation of the SQL-type NUMERIC(2,2)? The column is meant to hold a value representing time (e.g. number of years). I've seen examples were BigDecimal is used as a wrapper but that seems like overkill in this case.
 
Scott Selikoff
author
Bartender
Posts: 4081
21
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can you integer type such as (int) or (short). For example, monetary values are often stored in cents (multiplied by 100) so that no decimals are needed. You could also use float for less precision than double, but that's about it.

If you need something that strongly behaves like NUMERIC(2,2), such as enforcing constraints, etc, you should write your own wrapper class.
 
Kristofer Hindersson
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you! Quick and informative, just the way I like it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!