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