1Copyright (C) 2016 and later: Unicode, Inc. and others. 2License & terms of use: http://www.unicode.org/copyright.html 3 4Copyright (c) 2002-2010, International Business Machines Corporation and others. All Rights Reserved. 5 6 7IMPORTANT: 8 9This sample was originally intended as an exercise for the ICU Workshop (September 2000). 10The code currently provided in the solution file is the answer to the exercises, each step can still be found in the 'answers' subdirectory. 11 12 13 14 15 http://www.icu-project.org/docs/workshop_2000/agenda.html 16 17 Day 2: September 12th 2000 18 Pre-requisites: 19 1. All the hardware and software requirements from Day 1. 20 2. Attended or fully understand Day 1 material. 21 3. Read through the ICU user's guide at https://unicode-org.github.io/icu/userguide/. 22 23 #Date/Time/Number Formatting Support 24 9:30am - 10:30am 25 Alan Liu 26 27 Topics: 28 1. What is the date/time support in ICU? 29 2. What is the timezone support in ICU? 30 3. What kind of formatting and parsing support is available in ICU, i.e. 31 NumberFormat, DateFormat, MessageFormat? 32 33 34INSTRUCTIONS 35------------ 36 37 38This exercise was first developed and tested on ICU release 1.6.0, Win32, 39Microsoft Visual C++ 6.0. It should work on other ICU releases and 40other platforms as well. 41 42 MSVC: 43 Open the file "msgfmt.sln" in Microsoft Visual C++. 44 45 Unix: 46 - Build and install ICU with a prefix, for example '--prefix=/home/srl/ICU' 47 - Set the variable ICU_PREFIX=/home/srl/ICU and use GNU make in 48 this directory. 49 - You may use 'make check' to invoke this sample. 50 51PROBLEMS 52-------- 53 54Problem 0: 55 56 Set up the program, build it, and run it. To start with, the 57 program prints out the word "Message". 58 59Problem 1: Basic Message Formatting (Easy) 60 61 Use a MessageFormat to create a message that prints out "Received 62 <n> argument(s) on <d>.", where n is the number of command line 63 arguments (use argc-1), and d is the date (use Calendar::getNow()). 64 65 HINT: Your message pattern should have a "number" element and a 66 "date" element, and you will need to use Formattable. 67 68Problem 2: ChoiceFormat (Medium) 69 70 We can do better than "argument(s)". Instead, we can display more 71 idiomatic strings, such as "no arguments", "one argument", "two 72 arguments", and for higher values, we can use a number format. 73 74 This kind of value-based switching is done using a ChoiceFormat. 75 However, you seldom needs to create a ChoiceFormat by itself. 76 Instead, most of the time you will supply the ChoiceFormat pattern 77 within a MessageFormat pattern. 78 79 Use a ChoiceFormat pattern within the MessageFormat pattern, instead 80 of the "number" element, to display more idiomatic strings. 81 82 EXTRA: Embed a number element within the choice element to handle 83 values greater than two. 84 85 86ANSWERS 87------- 88 89The exercise includes answers. These are in the "answers" directory, 90and are numbered 1, 2, etc. 91 92If you get stuck and you want to move to the next step, copy the 93answers file into the main directory in order to proceed. E.g., 94"main_1.cpp" contains the original "main.cpp" file. "main_2.cpp" 95contains the "main.cpp" file after problem 1. Etc. 96 97 98Have fun! 99