Source Code Cross Referenced for LocalSDF.java in  » Web-Framework » RSF » uk » org » ponder » dateutil » 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 » RSF » uk.org.ponder.dateutil 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


01:        /*
02:         * Created on Apr 1, 2005
03:         */
04:        package uk.org.ponder.dateutil;
05:
06:        import java.text.SimpleDateFormat;
07:        import java.util.Date;
08:        import java.util.TimeZone;
09:
10:        /**
11:         * A thread-local SimpleDateFormat wrapper. If the default constructor is
12:         * used, supplies a W3C standard date format with millisecond resolution.
13:         * This class is somewhat useful since construction of a SimpleDateFormat runs
14:         * at around 13µs (2Ghz A64), with ThreadLocal gets around 300 times faster at
15:         * 40ns or so. NB, GregorianCalendar runs at about 2µs.
16:         * @author Antranig Basman (antranig@caret.cam.ac.uk)
17:         * 
18:         */
19:        public class LocalSDF {
20:            /** this represents W3C (ISO-8601) standard dates as defined in 
21:             * http://www.w3.org/TR/NOTE-datetime */
22:            public static final String W3C_DATE = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
23:            /** An 8601 format with a variable timezone **/
24:            public static final String W3C_DATE_TZ = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
25:            /** An 8601 format with a truncated (forced) timezone **/
26:            public static final String W3C_DATE_NOTZ = "yyyy-MM-dd'T'HH:mm:ss.SSS";
27:            /** A format to easy breaking dates into field representations **/
28:            public static final String BREAKER_DATE = "ddMMyyyyHHmmss";
29:
30:            public static LocalSDF w3cformat = new LocalSDF();
31:            public static LocalSDF breakformat = new LocalSDF(BREAKER_DATE);
32:
33:            private String formatstring;
34:            private ThreadLocal formatter = new ThreadLocal() {
35:                public Object initialValue() {
36:                    if (formatstring == null) {
37:                        SimpleDateFormat format = new SimpleDateFormat(W3C_DATE);
38:                        format.setTimeZone(TimeZone.getTimeZone("UTC"));
39:                        format.setLenient(false);
40:                        return format;
41:                    }
42:                    return new SimpleDateFormat(formatstring);
43:                }
44:            };
45:
46:            public LocalSDF() {
47:            }
48:
49:            public LocalSDF(String formatstring) {
50:                this .formatstring = formatstring;
51:            }
52:
53:            public SimpleDateFormat get() {
54:                return (SimpleDateFormat) formatter.get();
55:            }
56:
57:            public String format(Date toformat) {
58:                return get().format(toformat);
59:            }
60:
61:            public Date parse(String datestring) {
62:                Date parsed = DateUtil.parse(get(), datestring);
63:                return parsed;
64:            }
65:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.