Source Code Cross Referenced for IntlTestDateFormatAPIC.java in  » Internationalization-Localization » icu4j » com » ibm » icu » dev » test » format » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Internationalization Localization » icu4j » com.ibm.icu.dev.test.format 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *******************************************************************************
003:         * Copyright (C) 2001-2004, International Business Machines Corporation and    *
004:         * others. All Rights Reserved.                                                *
005:         *******************************************************************************
006:         */
007:
008:        /** 
009:         * Port From:   ICU4C v1.8.1 : format : IntlTestDateFormatAPI
010:         * Source File: $ICU4CRoot/source/test/intltest/dtfmapts.cpp
011:         **/package com.ibm.icu.dev.test.format;
012:
013:        import com.ibm.icu.text.*;
014:        import java.util.Date;
015:        import java.text.FieldPosition;
016:        import java.text.ParsePosition;
017:
018:        /*
019:         * This is an API test, not a unit test.  It doesn't test very many cases, and doesn't
020:         * try to test the full functionality.  It just calls each function in the class and
021:         * verifies that it works on a basic level.
022:         */
023:        public class IntlTestDateFormatAPIC extends
024:                com.ibm.icu.dev.test.TestFmwk {
025:
026:            public static void main(String[] args) throws Exception {
027:                new IntlTestDateFormatAPIC().run(args);
028:            }
029:
030:            /**
031:             * Test hiding of parse() and format() APIs in the Format hierarchy.
032:             * We test the entire hierarchy, even though this test is located in
033:             * the DateFormat API test.
034:             */
035:            public void TestNameHiding() {
036:
037:                // N.B.: This test passes if it COMPILES, since it's a test of
038:                // compile-time name hiding.
039:
040:                Date dateObj = new Date(0);
041:                Number numObj = new Double(3.1415926535897932384626433832795);
042:                StringBuffer strBuffer = new StringBuffer("");
043:                String str;
044:                FieldPosition fpos = new FieldPosition(0);
045:                ParsePosition ppos = new ParsePosition(0);
046:
047:                // DateFormat calling Format API
048:                {
049:                    logln("DateFormat");
050:                    DateFormat dateFmt = DateFormat.getInstance();
051:                    if (dateFmt != null) {
052:                        str = dateFmt.format(dateObj);
053:                        strBuffer = dateFmt.format(dateObj, strBuffer, fpos);
054:                    } else {
055:                        errln("FAIL: Can't create DateFormat");
056:                    }
057:                }
058:
059:                // SimpleDateFormat calling Format & DateFormat API
060:                {
061:                    logln("SimpleDateFormat");
062:                    SimpleDateFormat sdf = new SimpleDateFormat();
063:                    // Format API
064:                    str = sdf.format(dateObj);
065:                    strBuffer = sdf.format(dateObj, strBuffer, fpos);
066:                    // DateFormat API
067:                    strBuffer = sdf.format(new Date(0), strBuffer, fpos);
068:                    str = sdf.format(new Date(0));
069:                    try {
070:                        sdf.parse(str);
071:                        sdf.parse(str, ppos);
072:                    } catch (java.text.ParseException pe) {
073:                        System.out.println(pe);
074:                    }
075:                }
076:
077:                // NumberFormat calling Format API
078:                {
079:                    logln("NumberFormat");
080:                    NumberFormat fmt = NumberFormat.getInstance();
081:                    if (fmt != null) {
082:                        str = fmt.format(numObj);
083:                        strBuffer = fmt.format(numObj, strBuffer, fpos);
084:                    } else {
085:                        errln("FAIL: Can't create NumberFormat");
086:                    }
087:                }
088:
089:                // DecimalFormat calling Format & NumberFormat API
090:                {
091:                    logln("DecimalFormat");
092:                    DecimalFormat fmt = new DecimalFormat();
093:                    // Format API
094:                    str = fmt.format(numObj);
095:                    strBuffer = fmt.format(numObj, strBuffer, fpos);
096:                    // NumberFormat API
097:                    str = fmt.format(2.71828);
098:                    str = fmt.format(1234567);
099:                    strBuffer = fmt.format(1.41421, strBuffer, fpos);
100:                    strBuffer = fmt.format(9876543, strBuffer, fpos);
101:                    Number obj = fmt.parse(str, ppos);
102:                    try {
103:                        obj = fmt.parse(str);
104:                        if (obj == null) {
105:                            errln("FAIL: The format object could not parse the string : "
106:                                    + str);
107:                        }
108:                    } catch (java.text.ParseException pe) {
109:                        System.out.println(pe);
110:                    }
111:                }
112:
113:                //ICU4J have not the classes ChoiceFormat and MessageFormat
114:                /*
115:                // ChoiceFormat calling Format & NumberFormat API
116:                {
117:                    logln("ChoiceFormat");
118:                    ChoiceFormat fmt = new ChoiceFormat("0#foo|1#foos|2#foos");
119:                    // Format API
120:                    str = fmt.format(numObj);
121:                    strBuffer = fmt.format(numObj, strBuffer, fpos);
122:                    // NumberFormat API
123:                    str = fmt.format(2.71828);
124:                    str = fmt.format(1234567);
125:                    strBuffer = fmt.format(1.41421, strBuffer, fpos);
126:                    strBuffer = fmt.format(9876543, strBuffer, fpos);
127:                    Number obj = fmt.parse(str, ppos);
128:                    try {
129:                        obj = fmt.parse(str);
130:                    } catch (java.text.ParseException pe) {
131:                        System.out.println(pe);
132:                    }
133:                }
134:                
135:                
136:                // MessageFormat calling Format API
137:                {
138:                    logln("MessageFormat");
139:                    MessageFormat fmt = new MessageFormat("");
140:                    // Format API
141:                    // We use dateObj, which MessageFormat should reject.
142:                    // We're testing name hiding, not the format method.
143:                    try {
144:                        str = fmt.format(dateObj);
145:                    } catch (Exception e) {
146:                        //e.printStackTrace();
147:                    }
148:                    try {
149:                        strBuffer = fmt.format(dateObj, strBuffer, fpos);
150:                    } catch (Exception e) {
151:                        //e.printStackTrace();
152:                    }
153:                }
154:                 */
155:            }
156:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.