1 Copyright (c) 2002-2005, International Business Machines Corporation and others. All Rights Reserved.
2 This is an exercise for the ICU Workshop (September 2000).
4 http://icu.sourceforge.net/docs/workshop_2000/agenda.html
6 Day 2: September 12th 2000
8 1. All the hardware and software requirements from Day 1.
9 2. Attended or fully understand Day 1 material.
10 3. Read through the ICU user's guide at
11 http://icu.sourceforge.net/userguide/.
13 #Date/Time/Number Formatting Support
18 1. What is the date/time support in ICU?
19 2. What is the timezone support in ICU?
20 3. What kind of formatting and parsing support is available in ICU, i.e.
21 NumberFormat, DateFormat, MessageFormat?
28 This exercise was first developed and tested on ICU release 1.6.0, Win32,
29 Microsoft Visual C++ 6.0. It should work on other ICU releases and
30 other platforms as well.
33 Open the file "msgfmt.sln" in Microsoft Visual C++.
36 - Build and install ICU with a prefix, for example '--prefix=/home/srl/ICU'
37 - Set the variable ICU_PREFIX=/home/srl/ICU and use GNU make in
39 - You may use 'make check' to invoke this sample.
46 Set up the program, build it, and run it. To start with, the
47 program prints out the word "Message".
49 Problem 1: Basic Message Formatting (Easy)
51 Use a MessageFormat to create a message that prints out "Received
52 <n> argument(s) on <d>.", where n is the number of command line
53 arguments (use argc-1), and d is the date (use Calendar::getNow()).
55 HINT: Your message pattern should have a "number" element and a
56 "date" element, and you will need to use Formattable.
58 Problem 2: ChoiceFormat (Medium)
60 We can do better than "argument(s)". Instead, we can display more
61 idiomatic strings, such as "no arguments", "one argument", "two
62 arguments", and for higher values, we can use a number format.
64 This kind of value-based switching is done using a ChoiceFormat.
65 However, you seldom needs to create a ChoiceFormat by itself.
66 Instead, most of the time you will supply the ChoiceFormat pattern
67 within a MessageFormat pattern.
69 Use a ChoiceFormat pattern within the MessageFormat pattern, instead
70 of the "number" element, to display more idiomatic strings.
72 EXTRA: Embed a number element within the choice element to handle
73 values greater than two.
79 The exercise includes answers. These are in the "answers" directory,
80 and are numbered 1, 2, etc.
82 If you get stuck and you want to move to the next step, copy the
83 answers file into the main directory in order to proceed. E.g.,
84 "main_1.cpp" contains the original "main.cpp" file. "main_2.cpp"
85 contains the "main.cpp" file after problem 1. Etc.