Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieving format string from Format object

In Java is there a way to retrieve the format string from a Format object (or any derived classes)

In code:

Format f = new DecimalFormat("$0.00");
System.out.println(???);

Is there something I can use to get System.out.println(???); to print "$0.00".

I looked at toPattern(); but that function doesn't appear in the abstract Format class and the variable I'm working with can be anything that extends Format.

like image 272
ihumanable Avatar asked Sep 20 '26 21:09

ihumanable


1 Answers

The pattern (if there is any at all) depends on the subclass of Format. There is no guarantee that a Format would even use a pattern for its formatting.

Edit: I'm not sure what you're trying to do, but if you need to persist a Format instance, it is Serializable.

like image 179
Steve Kuo Avatar answered Sep 22 '26 12:09

Steve Kuo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!