Source Code Cross Referenced for StandardFieldDateTransit.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) 


001:        /*
002:         * Created on 7 Nov 2006
003:         */
004:        package uk.org.ponder.dateutil;
005:
006:        import java.text.DateFormat;
007:        import java.text.ParseException;
008:        import java.text.SimpleDateFormat;
009:        import java.util.Date;
010:        import java.util.Locale;
011:        import java.util.TimeZone;
012:
013:        import uk.org.ponder.localeutil.LocaleReceiver;
014:
015:        /**
016:         * A transit bean parsing Date objects into their Locale-specific forms.
017:         * 
018:         * @author Antranig Basman (antranig@caret.cam.ac.uk)
019:         */
020:
021:        public class StandardFieldDateTransit extends LocaleReceiver implements 
022:                FieldDateTransit {
023:            private Date date;
024:
025:            private SimpleDateFormat shortformat;
026:            private DateFormat medformat;
027:            private DateFormat longformat;
028:            private SimpleDateFormat timeformat;
029:            private DateFormat longtimeformat;
030:            private DateFormat iso8601tz;
031:            private DateFormat iso8601notz;
032:            //private DateFormat breakformat;
033:            private TimeZone timezone = TimeZone.getDefault();
034:
035:            public void setTimeZone(TimeZone timezone) {
036:                this .timezone = timezone;
037:            }
038:
039:            public int getTZOffset() {
040:                return timezone.getOffset(date.getTime());
041:            }
042:
043:            public void init() {
044:
045:                Locale locale = getLocale();
046:                // TODO: Think about sharing these, see LocalSDF for construction costs
047:                shortformat = (SimpleDateFormat) DateFormat.getDateInstance(
048:                        DateFormat.SHORT, locale);
049:                shortformat.setLenient(false);
050:                medformat = DateFormat.getDateInstance(DateFormat.MEDIUM,
051:                        locale);
052:                longformat = DateFormat
053:                        .getDateInstance(DateFormat.LONG, locale);
054:                timeformat = (SimpleDateFormat) DateFormat.getTimeInstance(
055:                        DateFormat.SHORT, locale);
056:                timeformat.setTimeZone(timezone);
057:                longtimeformat = DateFormat.getTimeInstance(DateFormat.LONG,
058:                        locale);
059:                longtimeformat.setTimeZone(timezone);
060:                iso8601tz = new SimpleDateFormat(LocalSDF.W3C_DATE_TZ);
061:                iso8601notz = new SimpleDateFormat(LocalSDF.W3C_DATE_NOTZ);
062:                iso8601notz.setTimeZone(timezone);
063:                //breakformat = new SimpleDateFormat(LocalSDF.BREAKER_DATE, locale);
064:                // do not use new Date(0) because of TZ insanity!!!
065:                date = LocalSDF.breakformat.parse("01012000000000");
066:            }
067:
068:            public String getShort() {
069:                return shortformat.format(date);
070:            }
071:
072:            public String getMedium() {
073:                return medformat.format(date);
074:            }
075:
076:            public String getLong() {
077:                return longformat.format(date);
078:            }
079:
080:            public String getTime() {
081:                return timeformat.format(date);
082:            }
083:
084:            public String getLongTime() {
085:                return longtimeformat.format(date);
086:            }
087:
088:            public void setShort(String shortform) throws ParseException {
089:                Date ydate = shortformat.parse(shortform);
090:                DateUtil.applyFields(date, ydate, DateUtil.DATE_FIELDS);
091:            }
092:
093:            public void setMedium(String medform) throws ParseException {
094:                Date ydate = medformat.parse(medform);
095:                DateUtil.applyFields(date, ydate, DateUtil.DATE_FIELDS);
096:            }
097:
098:            public void setLong(String longform) throws ParseException {
099:                Date ydate = longformat.parse(longform);
100:                DateUtil.applyFields(date, ydate, DateUtil.DATE_FIELDS);
101:            }
102:
103:            public void setTime(String time) throws ParseException {
104:                Date mdate = timeformat.parse(time);
105:                DateUtil.applyFields(date, mdate, DateUtil.TIME_FIELDS);
106:            }
107:
108:            public Date getDate() {
109:                return date;
110:            }
111:
112:            public void setDate(Date date) {
113:                this .date = date;
114:            }
115:
116:            /** Render an ISO8601-formatted value, including timezone information **/
117:            public String getISO8601TZ() {
118:                return iso8601tz.format(date);
119:            }
120:
121:            /** Set an ISO 8601-formatted value for which the timezone is to be firmly
122:             * IGNORED.
123:             */
124:            public void setISO8601TZ(String isoform) throws ParseException {
125:                date = iso8601notz.parse(isoform);
126:            }
127:
128:            public String getShortFormat() {
129:                return shortformat.toLocalizedPattern();
130:            }
131:
132:            public String getTimeFormat() {
133:                return timeformat.toLocalizedPattern();
134:            }
135:
136:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.