mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8300077: Refactor code examples to use @snippet in java.text.ChoiceFormat
Reviewed-by: lancea, iris, naoto
This commit is contained in:
parent
d117350875
commit
dcf1523bf2
1 changed files with 6 additions and 6 deletions
|
@ -85,7 +85,7 @@ import java.util.Arrays;
|
||||||
* <p>
|
* <p>
|
||||||
* Here is a simple example that shows formatting and parsing:
|
* Here is a simple example that shows formatting and parsing:
|
||||||
* <blockquote>
|
* <blockquote>
|
||||||
* <pre>{@code
|
* {@snippet lang=java :
|
||||||
* double[] limits = {1,2,3,4,5,6,7};
|
* double[] limits = {1,2,3,4,5,6,7};
|
||||||
* String[] dayOfWeekNames = {"Sun","Mon","Tue","Wed","Thur","Fri","Sat"};
|
* String[] dayOfWeekNames = {"Sun","Mon","Tue","Wed","Thur","Fri","Sat"};
|
||||||
* ChoiceFormat form = new ChoiceFormat(limits, dayOfWeekNames);
|
* ChoiceFormat form = new ChoiceFormat(limits, dayOfWeekNames);
|
||||||
|
@ -95,11 +95,11 @@ import java.util.Arrays;
|
||||||
* System.out.println(i + " -> " + form.format(i) + " -> "
|
* System.out.println(i + " -> " + form.format(i) + " -> "
|
||||||
* + form.parse(form.format(i),status));
|
* + form.parse(form.format(i),status));
|
||||||
* }
|
* }
|
||||||
* }</pre>
|
* }
|
||||||
* </blockquote>
|
* </blockquote>
|
||||||
* Here is a more complex example, with a pattern format:
|
* Here is a more complex example, with a pattern format:
|
||||||
* <blockquote>
|
* <blockquote>
|
||||||
* <pre>{@code
|
* {@snippet lang=java :
|
||||||
* double[] filelimits = {0,1,2};
|
* double[] filelimits = {0,1,2};
|
||||||
* String[] filepart = {"are no files","is one file","are {2} files"};
|
* String[] filepart = {"are no files","is one file","are {2} files"};
|
||||||
* ChoiceFormat fileform = new ChoiceFormat(filelimits, filepart);
|
* ChoiceFormat fileform = new ChoiceFormat(filelimits, filepart);
|
||||||
|
@ -112,13 +112,13 @@ import java.util.Arrays;
|
||||||
* testArgs[2] = testArgs[0];
|
* testArgs[2] = testArgs[0];
|
||||||
* System.out.println(pattform.format(testArgs));
|
* System.out.println(pattform.format(testArgs));
|
||||||
* }
|
* }
|
||||||
* }</pre>
|
* }
|
||||||
* </blockquote>
|
* </blockquote>
|
||||||
* <p>
|
* <p>
|
||||||
* Specifying a pattern for ChoiceFormat objects is fairly straightforward.
|
* Specifying a pattern for ChoiceFormat objects is fairly straightforward.
|
||||||
* For example:
|
* For example:
|
||||||
* <blockquote>
|
* <blockquote>
|
||||||
* <pre>{@code
|
* {@snippet lang=java :
|
||||||
* ChoiceFormat fmt = new ChoiceFormat(
|
* ChoiceFormat fmt = new ChoiceFormat(
|
||||||
* "-1#is negative| 0#is zero or fraction | 1#is one |1.0<is 1+ |2#is two |2<is more than 2.");
|
* "-1#is negative| 0#is zero or fraction | 1#is one |1.0<is 1+ |2#is two |2<is more than 2.");
|
||||||
* System.out.println("Formatter Pattern : " + fmt.toPattern());
|
* System.out.println("Formatter Pattern : " + fmt.toPattern());
|
||||||
|
@ -133,7 +133,7 @@ import java.util.Arrays;
|
||||||
* System.out.println("Format with 2.1 : " + fmt.format(2.1));
|
* System.out.println("Format with 2.1 : " + fmt.format(2.1));
|
||||||
* System.out.println("Format with NaN : " + fmt.format(Double.NaN));
|
* System.out.println("Format with NaN : " + fmt.format(Double.NaN));
|
||||||
* System.out.println("Format with +INF : " + fmt.format(Double.POSITIVE_INFINITY));
|
* System.out.println("Format with +INF : " + fmt.format(Double.POSITIVE_INFINITY));
|
||||||
* }</pre>
|
* }
|
||||||
* </blockquote>
|
* </blockquote>
|
||||||
* And the output result would be like the following:
|
* And the output result would be like the following:
|
||||||
* <blockquote>
|
* <blockquote>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue