I'm trying to do a simple logic with java.text.MessageFormat:
MessageFormat cf = new MessageFormat(
"{0,choice, 1<hello|5<{1,choice,1<more than one|4<more than four}}");
Object[] array = {3, 1};
System.out.println(cf.format(array));
With words: If the first parameter is greater then 1 print "hello", if it is greater than 5 than if the second parameter is greater than 1 print "more than one" if the second parameter is greater than 4 print "more than four".
I found no one saying it is impossible but I get an IllegalArgumentException:
Choice Pattern incorrect: 1<hello|5<{1,choice,1<more than one|4<more than four}
Is there a way I could do this? Thanks!
The whole stacktrace:
Exception in thread "main" java.lang.IllegalArgumentException: Choice Pattern incorrect: 1<hello|5<{1,choice,1<more than one|4<more than four}
at java.text.MessageFormat.makeFormat(Unknown Source)
at java.text.MessageFormat.applyPattern(Unknown Source)
at java.text.MessageFormat.<init>(Unknown Source)
at test.Test5.main(Test5.java:18)
Caused by: java.lang.IllegalArgumentException
at java.text.ChoiceFormat.applyPattern(Unknown Source)
at java.text.ChoiceFormat.<init>(Unknown Source)
... 4 more