[Solved] DecimalFormat to format minutes to hours


I need to pass the formatter to some other methods(for formatting Y axis in a bar chart)

I’ll leave the implementation details as a learning exercise for you, but one straightforward way would be to create your own subclass of DecimalFormat that overrides the various format methods, does the math, and passes the resulting modified number off to the base for the usual formatting.

When implementing this, make your goal to be to allow the base DecimalFormat to still do as much of the work as possible.

As an option, you may choose to parameterize your division factor instead of hardcoding e.g. 60, which will give you a better chance to reuse your new class in other situations.

solved DecimalFormat to format minutes to hours