I have a text field that displays 3 parameters with different formats. It has a Date value, a BigDecimal value and a value that has to be dis开发者_如何学Cplayed using percentage display.
Can I use a single text field for this or do I have to use one text field for each to have the correct format for each?
You have a few approaches, presuming it is one of the three parameters you want to display in the same location:
- Use three different fields and a
PrintWhenExpression
for each parameter. - Convert the different fields to a single String variable, with appropriate formatting, and then a single field for that variable value.
The second approach is probably the most applicable for your task. For the conversions, look at:
- BigDecimal.toString()
- SimpleDateFormat
- String.sprintf
See also:
Java: Literal percent sign in printf statement
精彩评论