1/********************************************************************
2 * COPYRIGHT:
3 * Copyright (c) 1999-2002, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 ********************************************************************/
6
7#include "unicode/unistr.h"
8#include "unicode/msgfmt.h"
9#include "unicode/calendar.h"
10#include <stdio.h>
11#include <stdlib.h>
12#include "util.h"
13
14// The message format pattern.  It takes a single argument, an integer,
15// and formats it as "no", "one", or a number, using a NumberFormat.
16static UnicodeString PATTERN(
17    "Received {0,choice,0#no arguments|1#one argument|2#{0,number,integer} arguments}"
18    " on {1,date,long}."
19);
20
21int main(int argc, char **argv) {
22
23    UErrorCode status = U_ZERO_ERROR;
24    UnicodeString str;
25    FieldPosition pos;
26
27    // Create a message format
28    MessageFormat msg(PATTERN, status);
29    check(status, "MessageFormat::ct");
30
31    // Create the argument list
32    Formattable msgArgs[2];
33    msgArgs[0].setLong(argc-1);
34    msgArgs[1].setDate(Calendar::getNow());
35
36    // Format the arguments
37    msg.format(msgArgs, 2, str, pos, status);
38    check(status, "MessageFormat::format");
39
40    printf("Message: ");
41    uprintf(str);
42    printf("\n");
43
44    printf("Exiting successfully\n");
45    return 0;
46}
47