Source Code Cross Referenced for ISOPeriodFormat.java in  » Development » Joda-Time » org » joda » time » 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 » Development » Joda Time » org.joda.time.format 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Copyright 2001-2005 Stephen Colebourne
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
011:         *  distributed under the License is distributed on an "AS IS" BASIS,
012:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         *  See the License for the specific language governing permissions and
014:         *  limitations under the License.
015:         */
016:        package org.joda.time.format;
017:
018:        /**
019:         * Factory that creates instances of PeriodFormatter for the ISO8601 standard.
020:         * <p>
021:         * Period formatting is performed by the {@link PeriodFormatter} class.
022:         * Three classes provide factory methods to create formatters, and this is one.
023:         * The others are {@link PeriodFormat} and {@link PeriodFormatterBuilder}.
024:         * <p>
025:         * ISOPeriodFormat is thread-safe and immutable, and the formatters it
026:         * returns are as well.
027:         *
028:         * @author Brian S O'Neill
029:         * @since 1.0
030:         * @see PeriodFormat
031:         * @see PeriodFormatterBuilder
032:         */
033:        public class ISOPeriodFormat {
034:
035:            /** Cache of standard format. */
036:            private static PeriodFormatter cStandard;
037:            /** Cache of alternate months format. */
038:            private static PeriodFormatter cAlternate;
039:            /** Cache of alternate extended months format. */
040:            private static PeriodFormatter cAlternateExtended;
041:            /** Cache of alternate weeks format. */
042:            private static PeriodFormatter cAlternateWithWeeks;
043:            /** Cache of alternate extended weeks format. */
044:            private static PeriodFormatter cAlternateExtendedWihWeeks;
045:
046:            /**
047:             * Constructor.
048:             *
049:             * @since 1.1 (previously private)
050:             */
051:            protected ISOPeriodFormat() {
052:                super ();
053:            }
054:
055:            //-----------------------------------------------------------------------
056:            /**
057:             * The standard ISO format - PyYmMwWdDThHmMsS.
058:             * Milliseconds are not output.
059:             * Note that the ISO8601 standard actually indicates weeks should not
060:             * be shown if any other field is present and vice versa.
061:             * 
062:             * @return the formatter
063:             */
064:            public static PeriodFormatter standard() {
065:                if (cStandard == null) {
066:                    cStandard = new PeriodFormatterBuilder().appendLiteral("P")
067:                            .appendYears().appendSuffix("Y").appendMonths()
068:                            .appendSuffix("M").appendWeeks().appendSuffix("W")
069:                            .appendDays().appendSuffix("D")
070:                            .appendSeparatorIfFieldsAfter("T").appendHours()
071:                            .appendSuffix("H").appendMinutes()
072:                            .appendSuffix("M")
073:                            .appendSecondsWithOptionalMillis()
074:                            .appendSuffix("S").toFormatter();
075:                }
076:                return cStandard;
077:            }
078:
079:            /**
080:             * The alternate ISO format, PyyyymmddThhmmss, which excludes weeks.
081:             * <p>
082:             * Even if weeks are present in the period, they are not output.
083:             * Fractional seconds (milliseconds) will appear if required.
084:             * 
085:             * @return the formatter
086:             */
087:            public static PeriodFormatter alternate() {
088:                if (cAlternate == null) {
089:                    cAlternate = new PeriodFormatterBuilder()
090:                            .appendLiteral("P").printZeroAlways()
091:                            .minimumPrintedDigits(4).appendYears()
092:                            .minimumPrintedDigits(2).appendMonths()
093:                            .appendDays().appendSeparatorIfFieldsAfter("T")
094:                            .appendHours().appendMinutes()
095:                            .appendSecondsWithOptionalMillis().toFormatter();
096:                }
097:                return cAlternate;
098:            }
099:
100:            /**
101:             * The alternate ISO format, Pyyyy-mm-ddThh:mm:ss, which excludes weeks.
102:             * <p>
103:             * Even if weeks are present in the period, they are not output.
104:             * Fractional seconds (milliseconds) will appear if required.
105:             * 
106:             * @return the formatter
107:             */
108:            public static PeriodFormatter alternateExtended() {
109:                if (cAlternateExtended == null) {
110:                    cAlternateExtended = new PeriodFormatterBuilder()
111:                            .appendLiteral("P").printZeroAlways()
112:                            .minimumPrintedDigits(4).appendYears()
113:                            .appendSeparator("-").minimumPrintedDigits(2)
114:                            .appendMonths().appendSeparator("-").appendDays()
115:                            .appendSeparatorIfFieldsAfter("T").appendHours()
116:                            .appendSeparator(":").appendMinutes()
117:                            .appendSeparator(":")
118:                            .appendSecondsWithOptionalMillis().toFormatter();
119:                }
120:                return cAlternateExtended;
121:            }
122:
123:            /**
124:             * The alternate ISO format, PyyyyWwwddThhmmss, which excludes months.
125:             * <p>
126:             * Even if months are present in the period, they are not output.
127:             * Fractional seconds (milliseconds) will appear if required.
128:             * 
129:             * @return the formatter
130:             */
131:            public static PeriodFormatter alternateWithWeeks() {
132:                if (cAlternateWithWeeks == null) {
133:                    cAlternateWithWeeks = new PeriodFormatterBuilder()
134:                            .appendLiteral("P").printZeroAlways()
135:                            .minimumPrintedDigits(4).appendYears()
136:                            .minimumPrintedDigits(2).appendPrefix("W")
137:                            .appendWeeks().appendDays()
138:                            .appendSeparatorIfFieldsAfter("T").appendHours()
139:                            .appendMinutes().appendSecondsWithOptionalMillis()
140:                            .toFormatter();
141:                }
142:                return cAlternateWithWeeks;
143:            }
144:
145:            /**
146:             * The alternate ISO format, Pyyyy-Www-ddThh:mm:ss, which excludes months.
147:             * <p>
148:             * Even if months are present in the period, they are not output.
149:             * Fractional seconds (milliseconds) will appear if required.
150:             * 
151:             * @return the formatter
152:             */
153:            public static PeriodFormatter alternateExtendedWithWeeks() {
154:                if (cAlternateExtendedWihWeeks == null) {
155:                    cAlternateExtendedWihWeeks = new PeriodFormatterBuilder()
156:                            .appendLiteral("P").printZeroAlways()
157:                            .minimumPrintedDigits(4).appendYears()
158:                            .appendSeparator("-").minimumPrintedDigits(2)
159:                            .appendPrefix("W").appendWeeks().appendSeparator(
160:                                    "-").appendDays()
161:                            .appendSeparatorIfFieldsAfter("T").appendHours()
162:                            .appendSeparator(":").appendMinutes()
163:                            .appendSeparator(":")
164:                            .appendSecondsWithOptionalMillis().toFormatter();
165:                }
166:                return cAlternateExtendedWihWeeks;
167:            }
168:
169:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.