README.TXT
1Copyright (c) 2002-2007, International Business Machines Corporation and others. All Rights Reserved.
2This is an exercise for the ICU Workshop (September 2000).
3
4 http://www.icu-project.org/docs/workshop_2000/agenda.html
5
6 Day 2: September 12th 2000
7 Pre-requisites:
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://www.icu-project.org/userguide/.
12
13 #Date/Time/Number Formatting Support
14 9:30am - 10:30am
15 Alan Liu
16
17 Topics:
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?
22
23
24INSTRUCTIONS
25------------
26
27
28This exercise was first developed and tested on ICU release 1.6.0, Win32,
29Microsoft Visual C++ 6.0. It should work on other ICU releases and
30other platforms as well.
31
32 MSVC:
33 Open the file "msgfmt.sln" in Microsoft Visual C++.
34
35 Unix:
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
38 this directory.
39 - You may use 'make check' to invoke this sample.
40
41PROBLEMS
42--------
43
44Problem 0:
45
46 Set up the program, build it, and run it. To start with, the
47 program prints out the word "Message".
48
49Problem 1: Basic Message Formatting (Easy)
50
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()).
54
55 HINT: Your message pattern should have a "number" element and a
56 "date" element, and you will need to use Formattable.
57
58Problem 2: ChoiceFormat (Medium)
59
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.
63
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.
68
69 Use a ChoiceFormat pattern within the MessageFormat pattern, instead
70 of the "number" element, to display more idiomatic strings.
71
72 EXTRA: Embed a number element within the choice element to handle
73 values greater than two.
74
75
76ANSWERS
77-------
78
79The exercise includes answers. These are in the "answers" directory,
80and are numbered 1, 2, etc.
81
82If you get stuck and you want to move to the next step, copy the
83answers file into the main directory in order to proceed. E.g.,
84"main_1.cpp" contains the original "main.cpp" file. "main_2.cpp"
85contains the "main.cpp" file after problem 1. Etc.
86
87
88Have fun!
89