1 /**********************************************************************
2 * Copyright (C) 2016 and later: Unicode, Inc. and others.
3 * License & terms of use: http://www.unicode.org/copyright.html#License
4 ***********************************************************************
5 ***********************************************************************
7 * Copyright (c) 1999-2002, International Business Machines Corporation and
8 * others. All Rights Reserved.
9 ***********************************************************************/
11 #include "unicode/unistr.h"
12 #include "unicode/msgfmt.h"
13 #include "unicode/calendar.h"
18 // The message format pattern. It takes a single argument, an integer,
19 // and formats it as "no", "one", or a number, using a NumberFormat.
20 static UnicodeString PATTERN(
21 "Received {0,choice,0#no arguments|1#one argument|2#{0,number,integer} arguments}"
25 int main(int argc, char **argv) {
27 UErrorCode status = U_ZERO_ERROR;
31 // Create a message format
32 MessageFormat msg(PATTERN, status);
33 check(status, "MessageFormat::ct");
35 // Create the argument list
36 Formattable msgArgs[2];
37 msgArgs[0].setLong(argc-1);
38 msgArgs[1].setDate(Calendar::getNow());
40 // Format the arguments
41 msg.format(msgArgs, 2, str, pos, status);
42 check(status, "MessageFormat::format");
48 printf("Exiting successfully\n");