Source Code Cross Referenced for IntlTestSimpleDateFormatAPI.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:         * (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
003:         * (C) Copyright IBM Corp. 1996-2005 - All Rights Reserved
004:         *
005:         *   The original version of this source code and documentation is copyrighted and
006:         * owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These materials are
007:         * provided under terms of a License Agreement between Taligent and Sun. This
008:         * technology is protected by multiple US and International patents. This notice and
009:         * attribution to Taligent may not be removed.
010:         *   Taligent is a registered trademark of Taligent, Inc.
011:         **/
012:
013:        /** 
014:         * Port From:   JDK 1.4b1 : java.text.Format.IntlTestSimpleDateFormatAPI
015:         * Source File: java/text/format/IntlTestSimpleDateFormatAPI.java
016:         **/package com.ibm.icu.dev.test.format;
017:
018:        import com.ibm.icu.text.*;
019:        import java.util.Locale;
020:        import java.util.Date;
021:        import java.text.ParsePosition;
022:        import java.text.Format;
023:        import java.text.FieldPosition;
024:        import java.text.ParseException;
025:
026:        public class IntlTestSimpleDateFormatAPI extends
027:                com.ibm.icu.dev.test.TestFmwk {
028:            public static void main(String[] args) throws Exception {
029:                new IntlTestSimpleDateFormatAPI().run(args);
030:            }
031:
032:            // This test checks various generic API methods in DecimalFormat to achieve 100% API coverage.
033:            public void TestAPI() {
034:                logln("SimpleDateFormat API test---");
035:                logln("");
036:
037:                Locale.setDefault(Locale.ENGLISH);
038:
039:                // ======= Test constructors
040:
041:                logln("Testing SimpleDateFormat constructors");
042:
043:                SimpleDateFormat def = new SimpleDateFormat();
044:
045:                final String pattern = new String(
046:                        "yyyy.MM.dd G 'at' hh:mm:ss z");
047:                SimpleDateFormat pat = new SimpleDateFormat(pattern);
048:
049:                SimpleDateFormat pat_fr = new SimpleDateFormat(pattern,
050:                        Locale.FRENCH);
051:
052:                DateFormatSymbols symbols = new DateFormatSymbols(Locale.FRENCH);
053:
054:                SimpleDateFormat cust1 = new SimpleDateFormat(pattern, symbols);
055:
056:                // ======= Test clone() and equality
057:
058:                logln("Testing clone(), assignment and equality operators");
059:
060:                Format clone = (Format) def.clone();
061:                if (!clone.equals(def)) {
062:                    errln("ERROR: Format clone or equals failed");
063:                }
064:
065:                // ======= Test various format() methods
066:
067:                logln("Testing various format() methods");
068:
069:                Date d = new Date((long) 837039928046.0);
070:
071:                StringBuffer res1 = new StringBuffer();
072:                StringBuffer res2 = new StringBuffer();
073:                FieldPosition pos1 = new FieldPosition(0);
074:                FieldPosition pos2 = new FieldPosition(0);
075:
076:                res1 = def.format(d, res1, pos1);
077:                logln("" + d.getTime() + " formatted to " + res1);
078:
079:                res2 = cust1.format(d, res2, pos2);
080:                logln("" + d.getTime() + " formatted to " + res2);
081:
082:                // ======= Test parse()
083:
084:                logln("Testing parse()");
085:
086:                String text = new String("02/03/76 2:50 AM, CST");
087:                Date result1 = new Date();
088:                Date result2 = new Date();
089:                ParsePosition pos = new ParsePosition(0);
090:                result1 = def.parse(text, pos);
091:                logln(text + " parsed into " + result1);
092:
093:                try {
094:                    result2 = def.parse(text);
095:                } catch (ParseException e) {
096:                    errln("ERROR: parse() failed");
097:                }
098:                logln(text + " parsed into " + result2);
099:
100:                // ======= Test getters and setters
101:
102:                logln("Testing getters and setters");
103:
104:                final DateFormatSymbols syms = pat.getDateFormatSymbols();
105:                def.setDateFormatSymbols(syms);
106:                pat_fr.setDateFormatSymbols(syms);
107:                if (!pat.getDateFormatSymbols().equals(
108:                        def.getDateFormatSymbols())) {
109:                    errln("ERROR: set DateFormatSymbols() failed");
110:                }
111:
112:                /*
113:                DateFormatSymbols has not the method getTwoDigitStartDate();
114:                //Date startDate = null; //The variable is never used
115:                try {
116:                //            startDate = pat.getTwoDigitStartDate();
117:                }
118:                catch (Exception e) {
119:                    errln("ERROR: getTwoDigitStartDate() failed");
120:                }
121:
122:                try {
123:                //            pat_fr.setTwoDigitStartDate(startDate);
124:                }
125:                catch (Exception e) {
126:                    errln("ERROR: setTwoDigitStartDate() failed");
127:                }*/
128:
129:                // ======= Test applyPattern()
130:                logln("Testing applyPattern()");
131:
132:                String p1 = new String("yyyy.MM.dd G 'at' hh:mm:ss z");
133:                logln("Applying pattern " + p1);
134:                pat.applyPattern(p1);
135:
136:                String s2 = pat.toPattern();
137:                logln("Extracted pattern is " + s2);
138:                if (!s2.equals(p1)) {
139:                    errln("ERROR: toPattern() result did not match pattern applied");
140:                }
141:
142:                logln("Applying pattern " + p1);
143:                pat.applyLocalizedPattern(p1);
144:                String s3 = pat.toLocalizedPattern();
145:                logln("Extracted pattern is " + s3);
146:                if (!s3.equals(p1)) {
147:                    errln("ERROR: toLocalizedPattern() result did not match pattern applied");
148:                }
149:
150:                // ======= Test getStaticClassID()
151:
152:                //        logln("Testing instanceof");
153:
154:                //        try {
155:                //            DateFormat test = new SimpleDateFormat();
156:
157:                //            if (! (test instanceof SimpleDateFormat)) {
158:                //                errln("ERROR: instanceof failed");
159:                //            }
160:                //        }
161:                //        catch (Exception e) {
162:                //            errln("ERROR: Couldn't create a SimpleDateFormat");
163:                //        }
164:            }
165:
166:            // Jitterbug 4451, for coverage
167:            public void TestCoverage() {
168:                class StubDateFormat extends SimpleDateFormat {
169:                    public void run() {
170:                        if (!zeroPaddingNumber(12, 4, 6).equals("0012")) {
171:                            errln("SimpleDateFormat(zeroPaddingNumber(long , int , int )");
172:                        }
173:                    }
174:                }
175:                new StubDateFormat().run();
176:            }
177:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.