Source Code Cross Referenced for DateFormatter.java in  » Web-Framework » TURBINE » org » apache » turbine » services » pull » util » 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 » Web Framework » TURBINE » org.apache.turbine.services.pull.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.turbine.services.pull.util;
002:
003:        /*
004:         * Licensed to the Apache Software Foundation (ASF) under one
005:         * or more contributor license agreements.  See the NOTICE file
006:         * distributed with this work for additional information
007:         * regarding copyright ownership.  The ASF licenses this file
008:         * to you under the Apache License, Version 2.0 (the
009:         * "License"); you may not use this file except in compliance
010:         * with the License.  You may obtain a copy of the License at
011:         *
012:         *   http://www.apache.org/licenses/LICENSE-2.0
013:         *
014:         * Unless required by applicable law or agreed to in writing,
015:         * software distributed under the License is distributed on an
016:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017:         * KIND, either express or implied.  See the License for the
018:         * specific language governing permissions and limitations
019:         * under the License.
020:         */
021:
022:        import java.util.Date;
023:
024:        import org.apache.commons.lang.StringUtils;
025:        import org.apache.commons.lang.time.DateFormatUtils;
026:        import org.apache.turbine.Turbine;
027:        import org.apache.turbine.services.pull.ApplicationTool;
028:
029:        /**
030:         * This pull tool is used to format date objects into strings.
031:         *
032:         * <p>As this is designed to be used as a gloal scope pull tool it needs to be
033:         * threadsafe.
034:         *
035:         * <p>This is an application pull tool for the template system. You should
036:         * <b>not</b> use it in a normal application.
037:         *
038:         * @author <a href="mailto:qmccombs@nequalsone.com">Quinton McCombs</a>
039:         * @author <a href="mailto:seade@backstagetech.com.au">Scott Eade</a>
040:         * @version $Id: DateFormatter.java 535251 2007-05-04 14:19:16Z seade $
041:         */
042:        public class DateFormatter implements  ApplicationTool {
043:            /** Default date format */
044:            private static final String DATE_FORMAT_DEFAULT = "MM/dd/yyyy";
045:
046:            /**
047:             * Property tag for the date format that is to be used for the web
048:             * application.
049:             */
050:            private static final String DATE_FORMAT_KEY = "tool.dateTool.format";
051:
052:            private String dateFormat = null;
053:
054:            /**
055:             * Initialize the application tool. The data parameter holds a different
056:             * type depending on how the tool is being instantiated:
057:             * <ul>
058:             * <li>For global tools data will be null
059:             * <li>For request tools data will be of type RunData
060:             * <li>For session and persistent tools data will be of type User
061:             *
062:             * @param data initialization data
063:             */
064:            public void init(Object data) {
065:                dateFormat = Turbine.getConfiguration().getString(
066:                        DATE_FORMAT_KEY, DATE_FORMAT_DEFAULT);
067:            }
068:
069:            /**
070:             * Refresh the application tool. This is necessary for development work
071:             * where you probably want the tool to refresh itself if it is using
072:             * configuration information that is typically cached after initialization.
073:             */
074:            public void refresh() {
075:            }
076:
077:            /**
078:             * Formats the given date as a String using the default date format.
079:             * The default date format is MM/dd/yyyy
080:             *
081:             * @param theDate date to format
082:             * @return String value of the date
083:             */
084:            public String format(Date theDate) {
085:                return format(theDate, dateFormat);
086:            }
087:
088:            /**
089:             * Formats the given date as a String.
090:             *
091:             * @param theDate date to format
092:             * @param dateFormatString format string to use.  See
093:             * java.text.SimpleDateFormat for details.
094:             * @return String value of the date
095:             */
096:            public String format(Date theDate, String dateFormatString) {
097:                String result = null;
098:
099:                if (StringUtils.isEmpty(dateFormatString) || theDate == null) {
100:                    result = "";
101:                } else {
102:                    result = DateFormatUtils.format(theDate, dateFormatString);
103:                }
104:                return result;
105:            }
106:
107:            /**
108:             * Formats the given date as a String.
109:             *
110:             * @param theDate date to format
111:             * @param dateFormatString format string to use.  See 
112:             * java.text.SimpleDateFormat for details.
113:             * @return String value of the date
114:             */
115:            public String format(long theDate, String dateFormatString) {
116:                return DateFormatUtils.format(theDate, dateFormatString);
117:            }
118:
119:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.