Source Code Cross Referenced for DateTag.java in  » Blogger-System » thingamablog » net » sf » thingamablog » generator » 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 » Blogger System » thingamablog » net.sf.thingamablog.generator 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on Apr 23, 2004
003:         *
004:         * This file is part of Thingamablog. ( http://thingamablog.sf.net )
005:         *
006:         * Copyright (c) 2004, Bob Tantlinger All Rights Reserved.
007:         *
008:         * This program is free software; you can redistribute it and/or
009:         * modify it under the terms of the GNU General Public License
010:         * as published by the Free Software Foundation; either version 2
011:         * of the License, or (at your option) any later version.
012:         *
013:         * This program is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016:         * GNU General Public License for more details.
017:         * 
018:         * You should have received a copy of the GNU General Public License
019:         * along with this program; if not, write to the Free Software
020:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
021:         * USA.
022:         */
023:        package net.sf.thingamablog.generator;
024:
025:        import java.text.SimpleDateFormat;
026:        import java.util.Date;
027:        import java.util.Hashtable;
028:        import java.util.Locale;
029:
030:        /**
031:         * A tag for date-related values
032:         * 
033:         * @author Bob Tantlinger
034:         *
035:         */
036:        public class DateTag extends TemplateTag {
037:            /** Attribute name for the format value */
038:            public static final String FORMAT = "format";
039:            public static final String LANG = "lang";
040:            public static final String COUNTRY = "country";
041:
042:            public static final String RFC822 = "RFC822";
043:            public static final String RFC822_FORMAT = "EEE, dd MMM yyyy HH:mm:ss Z";
044:
045:            private Hashtable ht;
046:            private Locale locale = Locale.getDefault();
047:            private SimpleDateFormat df;
048:
049:            /**
050:             * Constructs a DateTag
051:             * 
052:             * @param name The name of the tag
053:             */
054:            public DateTag(String name) {
055:                super (name);
056:                ht = new Hashtable();
057:                ht.put(FORMAT, "dd/MM/yy h:mm");
058:                ht.put(LANG, "");
059:                ht.put(COUNTRY, "");
060:                df = new SimpleDateFormat(ht.get(FORMAT).toString());
061:            }
062:
063:            /* (non-Javadoc)
064:             * @see net.sf.thingamablog.tmpl.TemplateElement#getDefaultAttributes()
065:             */
066:            public Hashtable getDefaultAttributes() {
067:                return ht;
068:            }
069:
070:            /* (non-Javadoc)
071:             * @see net.sf.thingamablog.tmpl.TemplateElement#process(java.lang.Object, java.lang.String, java.util.Hashtable)
072:             */
073:            public String process(Object obj, Hashtable attribs) {
074:                SimpleDateFormat sdf = initFormatter(attribs);
075:                try {
076:                    return sdf.format((Date) obj);
077:                } catch (ClassCastException cce) {
078:                }
079:                return "";
080:            }
081:
082:            private SimpleDateFormat initFormatter(Hashtable ht) {
083:                if (ht.get(FORMAT).toString().equalsIgnoreCase(RFC822)) {
084:                    ht.put(FORMAT, RFC822_FORMAT);
085:                    ht.put(LANG, "en");
086:                    ht.put(COUNTRY, "US");
087:                }
088:
089:                if (ht.get(LANG).equals("") && ht.get(COUNTRY).equals("")) {
090:                    df.applyPattern(ht.get(FORMAT).toString());
091:                    return df; //no locale attribs specified so return default
092:                }
093:
094:                Locale loc = new Locale(locale.getLanguage(), locale
095:                        .getCountry());
096:                if (!ht.get(LANG).equals(""))
097:                    loc = new Locale(ht.get(LANG).toString(), loc.getCountry());
098:                if (!ht.get(COUNTRY).equals(""))
099:                    loc = new Locale(loc.getLanguage(), ht.get(COUNTRY)
100:                            .toString());
101:
102:                return new SimpleDateFormat(ht.get(FORMAT).toString(), loc);
103:            }
104:
105:            /**
106:             * Gets the locale of the date formatter
107:             * 
108:             * @return The locale
109:             */
110:            public Locale getLocale() {
111:                return locale;
112:            }
113:
114:            /**
115:             * Sets the locale of the date formatter
116:             * 
117:             * @param locale The locale
118:             */
119:            public void setLocale(Locale locale) {
120:                this .locale = locale;
121:                df = new SimpleDateFormat(ht.get(FORMAT).toString(), locale);
122:            }
123:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.