Source Code Cross Referenced for DateFormatter.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » core » web » 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 » ERP CRM Financial » Kuali Financial System » org.kuali.core.web.format 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2004 Jonathan M. Lehr
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         * http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
011:         * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
012:         * governing permissions and limitations under the License.
013:         * 
014:         * MODIFIED BY THE KUALI FOUNDATION
015:         */
016:        // begin Kuali Foundation modification
017:        package org.kuali.core.web.format;
018:
019:        // end Kuali Foundation modification
020:
021:        // begin Kuali Foundation modification
022:        // import order changed, and java.util.Calendar, org.kuali.KeyConstants and org.kuali.rice.KNSServiceLocator added
023:        import java.sql.Date;
024:        import java.text.ParseException;
025:        import java.util.Calendar;
026:
027:        import org.kuali.RiceKeyConstants;
028:        import org.kuali.rice.KNSServiceLocator;
029:
030:        /**
031:         * begin Kuali Foundation modification
032:         * This class is used to format Date objects.
033:         * end Kuali Foundation modification
034:         */
035:        public class DateFormatter extends Formatter {
036:            // begin Kuali Foundation modification
037:            // serialVersionUID changed from 1L
038:            private static final long serialVersionUID = 7612442662886603084L;
039:
040:            // end Kuali Foundation modification
041:
042:            // begin Kuali Foundation modification
043:            // static variables DATE_ERROR_KEY and PARSE_MSG removed
044:            // method public String getErrorKey() removed
045:            // end Kuali Foundation modification
046:
047:            // begin Kuali Foundation modification
048:            // added this method
049:            /**
050:             * 
051:             * For a given user input date, this method returns the exact string the user entered after the last slash. This allows the
052:             * formatter to distinguish between ambiguous values such as "/06" "/6" and "/0006"
053:             * 
054:             * @param date
055:             * @return
056:             */
057:            private String verbatimYear(String date) {
058:                String result = "";
059:
060:                int pos = date.lastIndexOf("/");
061:                if (pos >= 0) {
062:                    result = date.substring(pos);
063:                }
064:
065:                return result;
066:            }
067:
068:            // end Kuali Foundation modification
069:
070:            /**
071:             * Unformats its argument and return a java.util.Date instance initialized with the resulting string.
072:             * 
073:             * @return a java.util.Date intialized with the provided string
074:             */
075:            protected Object convertToObject(String target) {
076:                // begin Kuali Foundation modification
077:                try {
078:                    Date result = KNSServiceLocator.getDateTimeService()
079:                            .convertToSqlDate(target);
080:                    Calendar calendar = Calendar.getInstance();
081:                    calendar.setTime(result);
082:                    if (calendar.get(Calendar.YEAR) < 1000
083:                            && verbatimYear(target).length() < 4) {
084:                        throw new FormatException("illegal year format",
085:                                RiceKeyConstants.ERROR_DATE, target);
086:                    }
087:                    return result;
088:                } catch (ParseException e) {
089:                    throw new FormatException("parsing",
090:                            RiceKeyConstants.ERROR_DATE, target, e);
091:                }
092:                // end Kuali Foundation modification
093:            }
094:
095:            /**
096:             * Returns a string representation of its argument, formatted as a date with the "MM/dd/yyyy" format.
097:             * 
098:             * @return a formatted String
099:             */
100:            public Object format(Object value) {
101:                if (value == null)
102:                    return null;
103:                // begin Kuali Foundation modification
104:                return KNSServiceLocator.getDateTimeService().toDateString(
105:                        (java.util.Date) value);
106:                // end Kuali Foundation modification
107:            }
108:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.