Tagged articles
4 articles
Page 1 of 1
Architect's Guide
Architect's Guide
Jan 25, 2024 · Backend Development

Automatic Unit Conversion in Java Using Maps and Custom Annotations

This article explains how to automate unit conversions for Java DTOs by first using a Map to mark fields and an enum for conversion types, then enhancing the solution with a custom annotation and reflection to make the process more reusable and maintainable.

BackendReflectionUnit Conversion
0 likes · 10 min read
Automatic Unit Conversion in Java Using Maps and Custom Annotations
IT Xianyu
IT Xianyu
Apr 27, 2023 · Backend Development

Automatic Unit Conversion in Java Using Reflection and Custom Annotations

This article demonstrates how to automatically convert monetary, percentage, permillage and other numeric fields in Java DTOs by marking target properties with a map or a custom annotation, then applying reflection‑based logic to perform scaling, rounding and unit changes in a reusable utility class.

ReflectionUnit Conversionannotations
0 likes · 10 min read
Automatic Unit Conversion in Java Using Reflection and Custom Annotations