288Units of Measure
Units grouped by type. Each unit knows how many base units it is, so any two units of the same type convert.
Try it
Unit converter
value × factor(from) ÷ factor(to) - only units of the same type convert
2.5 km =
2500 m
2.5 × 1000 ÷ 1
| # | Code | Name | Symbol | Type | Base unit | Factor | Status | |
|---|---|---|---|---|---|---|---|---|
| 4 | SQM | Square metre | m² | Area | — | 1 | Active | ✏️ |
| 17 | WA2 | Square wah (ตารางวา) | ตร.ว. | Area | SQM (m²) | 4 | Active | ✏️ |
| 18 | NGAN | Ngan (งาน) | งาน | Area | SQM (m²) | 400 | Active | ✏️ |
| 19 | RAI | Rai (ไร่) | ไร่ | Area | SQM (m²) | 1600 | Active | ✏️ |
| 5 | PCS | Piece | pcs | Count | — | 1 | Active | ✏️ |
| 20 | PACK | Pack of 6 | pack | Count | PCS (pcs) | 6 | Active | ✏️ |
| 21 | DOZ | Dozen | doz | Count | PCS (pcs) | 12 | Active | ✏️ |
| 22 | BOX | Box of 24 | box | Count | PCS (pcs) | 24 | Active | ✏️ |
| 7 | MM | Millimetre | mm | Length | M (m) | 0.001 | Active | ✏️ |
| 8 | CM | Centimetre | cm | Length | M (m) | 0.01 | Active | ✏️ |
| 10 | IN | Inch | in | Length | M (m) | 0.0254 | Active | ✏️ |
| 11 | FT | Foot | ft | Length | M (m) | 0.3048 | Active | ✏️ |
| 1 | M | Metre | m | Length | — | 1 | Active | ✏️ |
| 9 | KM | Kilometre | km | Length | M (m) | 1000 | Active | ✏️ |
| 6 | MIN | Minute | min | Time | — | 1 | Active | ✏️ |
Showing 1–15 of 24
🎓 Learn: how this master is built table unit
Key points
- DECIMAL(18,6) ↔ BigDecimal: never use double for quantities or money.
- UnitService.convert(): value × factor(from) ÷ factor(to).
- The unit type comes from the Lookup table (302) UNIT_TYPE.
Code
- Entity
domain/Unit.java- Repository
repo/UnitRepository.java- Definition
MasterRegistry: "units"- Page / form
web/MasterController.java- Try-it panel
templates/tools/unit-converter.html- REST API
GET /api/units/convert?value=2.5&from=KM&to=M
SQL to try in SSMS (database MasterDataLabDB)
SELECT u.code, u.name, u.factor, b.code AS base_unit FROM unit u LEFT JOIN unit b ON b.id = u.base_unit_id ORDER BY u.unit_type, u.factor;