]>
git.saurik.com Git - apple/icu.git/blob - icuSources/samples/translit/answers/main_1.cpp
   1 /*********************************************************************** 
   2  * © 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/translit.h" 
  12 #include "unicode/rbt.h" 
  13 #include "unicode/unistr.h" 
  14 #include "unicode/calendar.h" 
  15 #include "unicode/datefmt.h" 
  21 int main(int argc
, char **argv
) { 
  26     UErrorCode status 
= U_ZERO_ERROR
; 
  27     Locale 
greece("el", "GR"); 
  28     UnicodeString str
, str2
; 
  30     // Create a calendar in the Greek locale 
  31     cal 
= Calendar::createInstance(greece
, status
); 
  32     check(status
, "Calendar::createInstance"); 
  35     fmt 
= DateFormat::createDateInstance(DateFormat::kFull
, greece
); 
  36     fmt
->setCalendar(*cal
); 
  38     // Create a default formatter 
  39     defFmt 
= DateFormat::createDateInstance(DateFormat::kFull
); 
  40     defFmt
->setCalendar(*cal
); 
  42     // Loop over various months 
  43     for (int32_t month 
= Calendar::JANUARY
; 
  44          month 
<= Calendar::DECEMBER
; 
  47         // Set the calendar to a date 
  49         cal
->set(1999, month
, 4); 
  51         // Format the date in default locale 
  53         defFmt
->format(cal
->getTime(status
), str
, status
); 
  54         check(status
, "DateFormat::format"); 
  59         // Format the date for Greece 
  61         fmt
->format(cal
->getTime(status
), str
, status
); 
  62         check(status
, "DateFormat::format"); 
  63         printf("Greek formatted date: "); 
  72     printf("Exiting successfully\n");