File: I18nFormat.java

package info (click to toggle)
checker-framework-java 3.2.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 22,840 kB
  • sloc: java: 145,910; xml: 839; sh: 518; makefile: 401; perl: 26
file content (52 lines) | stat: -rw-r--r-- 1,881 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import java.text.MessageFormat;
import java.util.Date;

public class I18nFormat {

    void test() {

        MessageFormat.format(
                "{0} {1, number} {2, time} {3, date} {4, choice, 0#zero}",
                "S", 1, new Date(), new Date(), 0);
        MessageFormat.format("{0, number}{1, number}", 1, 2);
        MessageFormat.format("{0, number}{0}", 1);

        // :: warning: (i18nformat.excess.arguments)
        MessageFormat.format("'{0, number}'", new Date(12));

        // :: warning: (i18nformat.missing.arguments)
        MessageFormat.format("''{0, time, short}''{1}{2, time} {33, number}{44444}'{''''", 0);

        // :: warning: (i18nformat.missing.arguments)
        MessageFormat.format("{0, number}{1, number}", 1);

        // :: warning: (i18nformat.argument.unused)
        MessageFormat.format("{1, number}", 1, 1);

        // :: warning: (i18nformat.excess.arguments)
        MessageFormat.format("{0, number}", 1, new Date());

        // :: warning: (i18nformat.indirect.arguments)
        MessageFormat.format("{0, number}", new Object[2]);

        MessageFormat.format("{0}", "S");
        MessageFormat.format("{0}", 1);
        MessageFormat.format("{0}", new Date());

        // :: error: (argument.type.incompatible)
        MessageFormat.format("{0, number}", "S");
        MessageFormat.format("{0, number}", 1);
        // :: error: (argument.type.incompatible)
        MessageFormat.format("{0, number}", new Date());

        // :: error: (argument.type.incompatible)
        MessageFormat.format("{0, time}", "S");
        MessageFormat.format("{0, time}", 1);
        MessageFormat.format("{0, time}", new Date());

        // :: error: (argument.type.incompatible)
        MessageFormat.format("{0, date}", "S");
        MessageFormat.format("{0, date}", 1);
        MessageFormat.format("{0, date}", new Date());
    }
}