<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-8574118689743302986.post3404210907888313321..comments</id><updated>2011-07-06T09:02:58.200+03:00</updated><category term='SOLID'/><category term='Reentrant Lock'/><category term='CXF'/><category term='TestNG'/><category term='Domain Driven Design'/><category term='JPA'/><category term='Performance'/><category term='Things Every Programmer Should Know'/><category term='Javassist'/><category term='ArrayList'/><category term='Enterprise Java'/><category term='JVM Language'/><category term='JCG'/><category term='DevOps'/><category term='MOXy'/><category term='String'/><category term='Java 7'/><category term='Java EE 7'/><category term='Jackson'/><category term='Instrumentation'/><category term='Big-Oh Notation'/><category term='Concurrency'/><category term='Testing'/><category term='Java Best Practices'/><category term='EJB'/><category term='XMLPull'/><category term='Code Generation'/><category term='Software Errors'/><category term='TDD'/><category term='CamelCase'/><category term='Code Reviews'/><category term='Java Memory'/><category term='HashSet'/><category term='JAXB'/><category term='ORM'/><category term='Modularity'/><category term='Layout Manager'/><category term='Solaris'/><category term='HBase'/><category term='Debugging'/><category term='Hudson'/><category term='Flex'/><category term='Doclava'/><category term='Java 8'/><category term='JMS'/><category term='Game Design'/><category term='Persistence'/><category term='Exact String Matching'/><category term='Coding Dojo'/><category term='Quartz'/><category term='JasperReports'/><category term='Packt'/><category term='Java EE6'/><category term='Jolokia'/><category term='OpenId'/><category term='iReport'/><category term='IoC'/><category term='Openfire'/><category term='Cake Pattern'/><category term='Byte array'/><category term='Logging'/><category term='Java Tutorials'/><category term='Recursion'/><category term='Kannel'/><category term='Rules'/><category term='ConcurrentLinkedHashMap'/><category term='Presentations'/><category term='Groovy'/><category term='Extreme Programming'/><category term='MyBatis'/><category term='Google ClientLogin'/><category term='Compression'/><category term='ASM'/><category term='Competition'/><category term='Netbeans'/><category term='Tomcat'/><category term='RESTeasy'/><category term='AspectJ'/><category term='Text To Speech'/><category term='Java messaging'/><category term='Agile'/><category term='Smack'/><category term='PlaceFinder'/><category term='Eclipse'/><category term='Java EE7'/><category term='Garbage Collection'/><category term='Tiles'/><category term='DateFormat'/><category term='Benchmarking'/><category term='Multithreading'/><category term='Datanucleus'/><category term='Python'/><category term='Mocks'/><category term='Cryptography'/><category term='AOP'/><category term='Performance and Scalability'/><category term='Cache'/><category term='MapReduce'/><category term='Method Handlers'/><category term='Spring Insight'/><category term='VirtualBox'/><category term='Simple'/><category term='Review'/><category term='Selenium'/><category term='Mock'/><category term='IntelliJ IDEA'/><category term='Aspect Oriented Programming'/><category term='Wowza'/><category term='DTO'/><category term='Interview'/><category term='Spring Security'/><category term='Felix'/><category term='Thread Pool'/><category term='Swing'/><category term='Software Reliability'/><category term='Function Composition'/><category term='Scala'/><category term='Jetty'/><category term='Drools'/><category term='Singleton Pattern'/><category term='EMMA'/><category term='Equinox'/><category term='Spring Data'/><category term='dbUnit'/><category term='Instant Messaging'/><category term='Akka'/><category term='C# API for Kannel'/><category term='Backlog'/><category term='Location Based Services'/><category term='JAX-WS'/><category term='DDD'/><category term='Camel'/><category term='Virtualization'/><category term='JSON'/><category term='Transcoding'/><category term='LowerCamelCase'/><category term='Pair Programming'/><category term='Preferences'/><category term='Facebook'/><category term='Apache Lucene'/><category term='Servlet'/><category term='Cloud'/><category term='ZK'/><category term='Sponsored Post'/><category term='Conventions'/><category term='Android Animations'/><category term='Android Gestures'/><category term='Annotations'/><category term='Spark'/><category term='Logback'/><category term='Profiling'/><category term='Riak'/><category term='RTMP To RTSP'/><category term='Software Development'/><category term='GlassFish'/><category term='HSQLDB'/><category term='Morphia'/><category term='Algorithms'/><category term='ADF'/><category term='Java scheduling'/><category term='Welcome'/><category term='AWS'/><category term='Distributed Computing'/><category term='App Engine'/><category term='jqGrid'/><category term='Twitter4j'/><category term='SmartGWT'/><category term='Ruby'/><category term='CountDownLatch'/><category term='Javadoc'/><category term='Linux'/><category term='Apache CXF'/><category term='FFmpeg'/><category term='Design Pattern'/><category term='WADL'/><category term='Java Proxy'/><category term='Callable'/><category term='Monitoring'/><category term='Proximity Alerts'/><category term='Weld'/><category term='SWT'/><category term='Erlang'/><category term='LeWeb'/><category term='TreeCache'/><category term='Decorator'/><category term='JSP'/><category term='SQL'/><category term='Infispan'/><category term='DBCP'/><category term='jOOQ'/><category term='Lambdas'/><category term='Code Analysis'/><category term='Testings'/><category term='Regular Expressions'/><category term='H.263'/><category term='Hibernate'/><category term='Sharding'/><category term='WebLogic'/><category term='RESTful Web Service'/><category term='JAAS'/><category term='WebDriver'/><category term='Validators'/><category term='Android Camera'/><category term='MongoDB'/><category term='Naming'/><category term='DOM'/><category term='Infinispan'/><category term='Git'/><category term='Guava'/><category term='findbugs'/><category term='Play Framework'/><category term='Atomikos'/><category term='Arquillian'/><category term='JBoss Modules'/><category term='CDI'/><category term='BlockingQueue'/><category term='Jersey'/><category term='Dependency Inversion'/><category term='Vaadin'/><category term='Cassandra'/><category term='Laws of Software Design'/><category term='Java API for Kannel'/><category term='jQuery'/><category term='MySQL'/><category term='Net Neutrality'/><category term='Stress Testing'/><category term='Interview questions'/><category term='Portal'/><category term='Hypersonic'/><category term='Android Tutorial'/><category term='Web Services'/><category term='ActiveMQ'/><category term='MVP'/><category term='CAPTCHA'/><category term='Anemic Domain Models'/><category term='XML'/><category term='Big Data'/><category term='Collection'/><category term='SAML'/><category term='Refactoring'/><category term='LDAP'/><category term='CouchDB'/><category term='Reverse Geocoding'/><category term='SAX'/><category term='Map'/><category term='LinkedHashMap'/><category term='Learning'/><category term='Apache Commons'/><category term='JMX'/><category term='W4G'/><category term='H.264'/><category term='Code Complexity'/><category term='GPS'/><category term='Code Optimization'/><category term='JSF'/><category term='Spring Cache'/><category term='JRockit'/><category term='Classloaders'/><category term='JavaMail'/><category term='Spring Dynamic Modules'/><category term='Estimations'/><category term='Serialization'/><category term='Continuous Deployment'/><category term='Software Devevelopment'/><category term='Redmine'/><category term='ObjectDB'/><category term='Queue'/><category term='Dojo'/><category term='Google Maps'/><category term='Mapped Collections'/><category term='Memory System'/><category term='Analytics'/><category term='Semaphores'/><category term='Fork Join'/><category term='GWT'/><category term='Architecture'/><category term='Scala Tutorial'/><category term='Dependency Injection'/><category term='EhCache'/><category term='Date'/><category term='HashMap'/><category term='Project Tracking'/><category term='Core Java'/><category term='Cajo'/><category term='Google Authenticator'/><category term='Configuration Management'/><category term='Security'/><category term='Log4j'/><category term='Future'/><category term='JavaOne'/><category term='Hive'/><category term='Java Generics'/><category term='Ivy'/><category term='Communications'/><category term='Archetype'/><category term='SMTP'/><category term='JNDI'/><category term='Devoxx'/><category term='CPU'/><category term='DB Schema'/><category term='PGP'/><category term='Hadoop'/><category term='Derby'/><category term='Neo4j'/><category term='Android Preferences'/><category term='RabbitMQ'/><category term='NIO'/><category term='Grails'/><category term='Spring'/><category term='JUnit'/><category term='HornetQ'/><category term='OpenCL'/><category term='Activiti'/><category term='Android'/><category term='JCuda'/><category term='Openshift'/><category term='Mahout'/><category term='Design Patterns'/><category term='Meta Java Code Geeks'/><category term='Guice'/><category term='Mail'/><category term='Heroku'/><category term='JBoss Portal'/><category term='JVM'/><category term='JBoss'/><category term='OSGi'/><category term='JIRA'/><category term='EJB3'/><category term='Apache Shiro'/><category term='JGroups'/><category term='Best Of The Week'/><category term='JTA'/><category term='YouTube API'/><category term='XMPP'/><category term='Android Games'/><category term='Coherence'/><category term='Naked Objects'/><category term='Readability'/><category term='Desktop Java'/><category term='Java'/><category term='Sonar'/><category term='Spring Tutorial'/><category term='NoSQL'/><category term='Web Service'/><category term='Gson'/><category term='Transactions'/><category term='JavaFX'/><category term='Cobertura'/><category term='C#'/><category term='Redis'/><category term='Portlet'/><category term='Spring MVC'/><category term='GPGPU'/><category term='Functional Programming'/><category term='Code Injection'/><category term='Authentication and Authorization'/><category term='Maven'/><category term='EclipseLink'/><category term='Andygene'/><category term='Geocoding'/><category term='Stat4j'/><category term='Xuggler'/><category term='Giveaway'/><category term='Vector'/><category term='Specifications'/><category term='Concurrent'/><category term='Axis2'/><category term='MAT'/><category term='PowerMock'/><category term='OpenJDK'/><category term='Character'/><category term='Books'/><title type='text'>Comments on Java Code Geeks: Java Best Practices – DateFormat in a Multithreadi...</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.javacodegeeks.com/feeds/3404210907888313321/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574118689743302986/3404210907888313321/comments/default'/><link rel='alternate' type='text/html' href='http://www.javacodegeeks.com/2010/07/java-best-practices-dateformat-in.html'/><author><name>Byron Kiourtzoglou</name><uri>http://www.blogger.com/profile/00834323472598416198</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>13</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8574118689743302986.post-4966570417588781684</id><published>2011-07-06T09:02:58.200+03:00</published><updated>2011-07-06T09:02:58.200+03:00</updated><title type='text'>You have implemented a simple multi thread testing...</title><content type='html'>You have implemented a simple multi thread testing framework of our own.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574118689743302986/3404210907888313321/comments/default/4966570417588781684'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574118689743302986/3404210907888313321/comments/default/4966570417588781684'/><link rel='alternate' type='text/html' href='http://www.javacodegeeks.com/2010/07/java-best-practices-dateformat-in.html?showComment=1309932178200#c4966570417588781684' title=''/><author><name>Byron Kiourtzoglou</name><uri>http://www.blogger.com/profile/00834323472598416198</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='08894282877057619649'/><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.javacodegeeks.com/2010/07/java-best-practices-dateformat-in.html' ref='tag:blogger.com,1999:blog-8574118689743302986.post-3404210907888313321' source='http://www.blogger.com/feeds/8574118689743302986/posts/default/3404210907888313321' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-689404176'/></entry><entry><id>tag:blogger.com,1999:blog-8574118689743302986.post-7363623435406886248</id><published>2011-07-06T06:50:59.074+03:00</published><updated>2011-07-06T06:50:59.074+03:00</updated><title type='text'>hi, which tool you used to generate performance re...</title><content type='html'>hi, which tool you used to generate performance report? thanks a lot~~</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574118689743302986/3404210907888313321/comments/default/7363623435406886248'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574118689743302986/3404210907888313321/comments/default/7363623435406886248'/><link rel='alternate' type='text/html' href='http://www.javacodegeeks.com/2010/07/java-best-practices-dateformat-in.html?showComment=1309924259074#c7363623435406886248' title=''/><author><name>飘落的枫叶</name><uri>http://www.blogger.com/profile/03273370487420280497</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://photos1.blogger.com/blogger/4109/2292/320/104f7011f52.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.javacodegeeks.com/2010/07/java-best-practices-dateformat-in.html' ref='tag:blogger.com,1999:blog-8574118689743302986.post-3404210907888313321' source='http://www.blogger.com/feeds/8574118689743302986/posts/default/3404210907888313321' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-989269121'/></entry><entry><id>tag:blogger.com,1999:blog-8574118689743302986.post-6606463562547942543</id><published>2011-05-17T08:13:30.099+03:00</published><updated>2011-05-17T08:13:30.099+03:00</updated><title type='text'>Problems go deeper than Formatters (Date, Number, ...</title><content type='html'>Problems go deeper than Formatters (Date, Number, etc) in Java. Actually, Date objects can mutate when read (!) as demonstrated here: http://hype-free.blogspot.com/2011/01/java-date-objects-can-mutate-even-when.html, which is completely unexpected and undocumented, so my recommendation is to use something like JodaTime.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574118689743302986/3404210907888313321/comments/default/6606463562547942543'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574118689743302986/3404210907888313321/comments/default/6606463562547942543'/><link rel='alternate' type='text/html' href='http://www.javacodegeeks.com/2010/07/java-best-practices-dateformat-in.html?showComment=1305609210099#c6606463562547942543' title=''/><author><name>cdman83</name><uri>http://www.blogger.com/profile/05030326541176171725</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='09441482122666272143'/><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://4.bp.blogspot.com/_hrvCBhtWhJ4/SPBrNYhIpxI/AAAAAAAAAMc/ylcGT7ni7S4/S220/maci.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.javacodegeeks.com/2010/07/java-best-practices-dateformat-in.html' ref='tag:blogger.com,1999:blog-8574118689743302986.post-3404210907888313321' source='http://www.blogger.com/feeds/8574118689743302986/posts/default/3404210907888313321' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-936704666'/></entry><entry><id>tag:blogger.com,1999:blog-8574118689743302986.post-9062585564603432406</id><published>2011-02-05T12:55:52.728+02:00</published><updated>2011-02-05T12:55:52.728+02:00</updated><title type='text'>Thanks for this nice explanation and the advantage...</title><content type='html'>Thanks for this nice explanation and the advantage of ThreadLocal!</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574118689743302986/3404210907888313321/comments/default/9062585564603432406'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574118689743302986/3404210907888313321/comments/default/9062585564603432406'/><link rel='alternate' type='text/html' href='http://www.javacodegeeks.com/2010/07/java-best-practices-dateformat-in.html?showComment=1296903352728#c9062585564603432406' title=''/><author><name>frickelblog</name><uri>http://frickelblog.wordpress.com/</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/openid16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.javacodegeeks.com/2010/07/java-best-practices-dateformat-in.html' ref='tag:blogger.com,1999:blog-8574118689743302986.post-3404210907888313321' source='http://www.blogger.com/feeds/8574118689743302986/posts/default/3404210907888313321' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1471989156'/></entry><entry><id>tag:blogger.com,1999:blog-8574118689743302986.post-7662044131400750064</id><published>2010-10-05T09:45:08.823+03:00</published><updated>2010-10-05T09:45:08.823+03:00</updated><title type='text'>Hello developmentech,

My point was to show an eff...</title><content type='html'>Hello developmentech,&lt;br /&gt;&lt;br /&gt;My point was to show an efficient way to properly utilize DateFormat in a multithreading environment. You definitelly NEED to access DateFormat instances in a synchronized manner if you intend to use them by multiple threads (when parsing also). We designate typical exceptions thrown when parsing to create a date and viceversa.&lt;br /&gt;&lt;br /&gt;Lastly if you are not convinced that parse needs to be synchronized you just have to implement a simple case schenario and test it for yourself. You will be amazed of how easy it is to experience errorneous results.&lt;br /&gt;&lt;br /&gt;BRs</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574118689743302986/3404210907888313321/comments/default/7662044131400750064'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574118689743302986/3404210907888313321/comments/default/7662044131400750064'/><link rel='alternate' type='text/html' href='http://www.javacodegeeks.com/2010/07/java-best-practices-dateformat-in.html?showComment=1286261108823#c7662044131400750064' title=''/><author><name>Justin Cater</name><uri>http://www.blogger.com/profile/11311508639617598691</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.javacodegeeks.com/2010/07/java-best-practices-dateformat-in.html' ref='tag:blogger.com,1999:blog-8574118689743302986.post-3404210907888313321' source='http://www.blogger.com/feeds/8574118689743302986/posts/default/3404210907888313321' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-2015425979'/></entry><entry><id>tag:blogger.com,1999:blog-8574118689743302986.post-6657574776918555902</id><published>2010-10-05T01:57:59.743+03:00</published><updated>2010-10-05T01:57:59.743+03:00</updated><title type='text'>I really have to ask why. In the examples, the onl...</title><content type='html'>I really have to ask why. In the examples, the only method being called (ultimately) on the date format object is parse. So, what class state on the date format object does parse change? I would be surprised if it changed any. The reason for the comment in the API for SimpleDateFormat not being synchronized is for the methods that DO change the state of the SimpleDateFormat object. But parse is not one of them.&lt;br /&gt;So, if your example was to show your prowess in using and explaining ThreadLocal, good job! You did that. But, if your point was to show that we NEEDED to use ThreadLocal when we are going to be parsing dates with a DateFormat, then I think you may have missed the mark because I am not convinced that parse needs to be synchronized.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574118689743302986/3404210907888313321/comments/default/6657574776918555902'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574118689743302986/3404210907888313321/comments/default/6657574776918555902'/><link rel='alternate' type='text/html' href='http://www.javacodegeeks.com/2010/07/java-best-practices-dateformat-in.html?showComment=1286233079743#c6657574776918555902' title=''/><author><name>developmentech</name><uri>http://developmentech.wordpress.com/</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/openid16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.javacodegeeks.com/2010/07/java-best-practices-dateformat-in.html' ref='tag:blogger.com,1999:blog-8574118689743302986.post-3404210907888313321' source='http://www.blogger.com/feeds/8574118689743302986/posts/default/3404210907888313321' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1416607022'/></entry><entry><id>tag:blogger.com,1999:blog-8574118689743302986.post-5388889140398981052</id><published>2010-07-31T14:07:42.708+03:00</published><updated>2010-07-31T14:07:42.708+03:00</updated><title type='text'>I had a look at org.apache.commons.lang.time.FastD...</title><content type='html'>I had a look at org.apache.commons.lang.time.FastDateFormat&amp;#39;s source code and it seems that all methods returning a DateFormat instance are synchronized. Although it uses some kind of internal caching it clearly can&amp;#39;t scale as well as the ThreadLocal approach since all threads need to wait until they acquire a monitor lock..&lt;br /&gt;&lt;br /&gt;Does anyone know if org.joda.time.format.DateTimeFormatter in Joda Time is thread safe? Nothing relevant seems to be mentioned in the class&amp;#39;s documentation.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574118689743302986/3404210907888313321/comments/default/5388889140398981052'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574118689743302986/3404210907888313321/comments/default/5388889140398981052'/><link rel='alternate' type='text/html' href='http://www.javacodegeeks.com/2010/07/java-best-practices-dateformat-in.html?showComment=1280574462708#c5388889140398981052' title=''/><author><name>Savvas-Andreas</name><uri>http://www.blogger.com/profile/13424412116937856542</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='02596642669046294931'/><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.javacodegeeks.com/2010/07/java-best-practices-dateformat-in.html' ref='tag:blogger.com,1999:blog-8574118689743302986.post-3404210907888313321' source='http://www.blogger.com/feeds/8574118689743302986/posts/default/3404210907888313321' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-423036677'/></entry><entry><id>tag:blogger.com,1999:blog-8574118689743302986.post-8364569858279364636</id><published>2010-07-25T21:08:31.677+03:00</published><updated>2010-07-25T21:08:31.677+03:00</updated><title type='text'>I wrote a ConcurrentDateFormat class which impleme...</title><content type='html'>I wrote a ConcurrentDateFormat class which implements DateFormat, it stores a cloned instance of a passed in DateFormat as a  template, so its initialValue() just returns a clone of the stored template.  This approach combines the best of ThreadLocal and cloning, and is completely transparent.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574118689743302986/3404210907888313321/comments/default/8364569858279364636'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574118689743302986/3404210907888313321/comments/default/8364569858279364636'/><link rel='alternate' type='text/html' href='http://www.javacodegeeks.com/2010/07/java-best-practices-dateformat-in.html?showComment=1280081311677#c8364569858279364636' title=''/><author><name>infernoz</name><uri>http://www.blogger.com/profile/09979978365171176951</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.javacodegeeks.com/2010/07/java-best-practices-dateformat-in.html' ref='tag:blogger.com,1999:blog-8574118689743302986.post-3404210907888313321' source='http://www.blogger.com/feeds/8574118689743302986/posts/default/3404210907888313321' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-561612260'/></entry><entry><id>tag:blogger.com,1999:blog-8574118689743302986.post-5308082690444853812</id><published>2010-07-16T20:07:19.415+03:00</published><updated>2010-07-16T20:07:19.415+03:00</updated><title type='text'>Hi! :)

I was just testint this stuff the other we...</title><content type='html'>Hi! :)&lt;br /&gt;&lt;br /&gt;I was just testint this stuff the other week, and I really think this is a dangerous subject many developers do not pay attention to.&lt;br /&gt;&lt;br /&gt;But I just found out a really nice way of doing it. Instead of synchronizing one instances, there are two better solutions, in my opinion:&lt;br /&gt;&lt;br /&gt;If you have lots of formatting, you should use a Flyweight pattern solution. In short, use a cache of instances.&lt;br /&gt;&lt;br /&gt;But that is not so simple and in most cases is like too much trouble. So comes the trick. =)&lt;br /&gt;Just create a static constant and use it as template by CLONING IT. ;)&lt;br /&gt;&lt;br /&gt;My testings showed that cloning a DateFormat, TextFormat and any other similiar is 20 times faster than creating a new one, if my memory does not fail me. =)&lt;br /&gt;&lt;br /&gt;Yes, just do&lt;br /&gt;DATE_FORMAT.clone().format(new Date());&lt;br /&gt;&lt;br /&gt;Maybe someday I post this test on my blog... :P</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574118689743302986/3404210907888313321/comments/default/5308082690444853812'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574118689743302986/3404210907888313321/comments/default/5308082690444853812'/><link rel='alternate' type='text/html' href='http://www.javacodegeeks.com/2010/07/java-best-practices-dateformat-in.html?showComment=1279300039415#c5308082690444853812' title=''/><author><name>tripl3DES</name><uri>http://www.blogger.com/profile/17410730366914745176</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.javacodegeeks.com/2010/07/java-best-practices-dateformat-in.html' ref='tag:blogger.com,1999:blog-8574118689743302986.post-3404210907888313321' source='http://www.blogger.com/feeds/8574118689743302986/posts/default/3404210907888313321' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1213049426'/></entry><entry><id>tag:blogger.com,1999:blog-8574118689743302986.post-1063863920377201658</id><published>2010-07-13T23:29:25.701+03:00</published><updated>2010-07-13T23:29:25.701+03:00</updated><title type='text'>You don&amp;#39;t need to override all methods on Thre...</title><content type='html'>You don&amp;#39;t need to override all methods on ThreadLocal - just initialValue:&lt;br /&gt;&lt;br /&gt;private ThreadLocal  df = new ThreadLocal () {&lt;br /&gt;  @Override&lt;br /&gt;  protected DateFormat initialValue() {&lt;br /&gt;   return new SimpleDateFormat(&amp;quot;yyyy MM dd&amp;quot;);&lt;br /&gt;  } &lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;On my project we wrapped this inside a ThreadsafeSimpleDateFormat which took a &lt;br /&gt;DateFormat as constructor argument, cloned it (for safety) and stored as &amp;quot;seed&amp;quot;. The initialValue() of our innerThreadLocal then returned seed.clone(). &lt;br /&gt;&lt;br /&gt;ThreadsafeSimpleDateFormat had parse and format methods which delegated to innerThreadLocal.get().&lt;br /&gt;&lt;br /&gt;If you&amp;#39;re REALLY paranoid, you&amp;#39;ll synchronize the call to seed.clone() on seed, since there is no guarantee that the clone() method is thread safe.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Apache commons FastDateFormat is great - except that it doesn&amp;#39;t do parsing.&lt;br /&gt;&lt;br /&gt;JodaTime is great, but requires you to use JodaTime instead of java.util.Date/java.util.Calendar. Great choice, but more intrusive.  &lt;br /&gt;&lt;br /&gt;Andrei&amp;#39;s solution also looks good, but could be implemented slightly more elegant in Java 5 with generics. &lt;br /&gt;&lt;br /&gt;One thing you must beware of is Locale.setDefault(). If you don&amp;#39;t provide a Locale when constructing your SimpleDateFormat, Locale.getDefault() will be used - whatever that is, at the time initialValue() is called. So if you change this later, it will NOT affect those ThreadLocal&amp;#39;s which have already been created, but it will affect those that are created later. Here be dragons.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574118689743302986/3404210907888313321/comments/default/1063863920377201658'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574118689743302986/3404210907888313321/comments/default/1063863920377201658'/><link rel='alternate' type='text/html' href='http://www.javacodegeeks.com/2010/07/java-best-practices-dateformat-in.html?showComment=1279052965701#c1063863920377201658' title=''/><author><name>Niels Ull</name><uri>http://www.blogger.com/profile/16998283210631387133</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.javacodegeeks.com/2010/07/java-best-practices-dateformat-in.html' ref='tag:blogger.com,1999:blog-8574118689743302986.post-3404210907888313321' source='http://www.blogger.com/feeds/8574118689743302986/posts/default/3404210907888313321' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1938601087'/></entry><entry><id>tag:blogger.com,1999:blog-8574118689743302986.post-4241488705406822428</id><published>2010-07-13T12:34:09.392+03:00</published><updated>2010-07-13T12:34:09.392+03:00</updated><title type='text'>Cheers! You just gave me a good hint on a task I&amp;#...</title><content type='html'>Cheers! You just gave me a good hint on a task I&amp;#39;m working on.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574118689743302986/3404210907888313321/comments/default/4241488705406822428'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574118689743302986/3404210907888313321/comments/default/4241488705406822428'/><link rel='alternate' type='text/html' href='http://www.javacodegeeks.com/2010/07/java-best-practices-dateformat-in.html?showComment=1279013649392#c4241488705406822428' title=''/><author><name>carrion</name><uri>http://www.blogger.com/profile/05719165404757540380</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.javacodegeeks.com/2010/07/java-best-practices-dateformat-in.html' ref='tag:blogger.com,1999:blog-8574118689743302986.post-3404210907888313321' source='http://www.blogger.com/feeds/8574118689743302986/posts/default/3404210907888313321' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1182741247'/></entry><entry><id>tag:blogger.com,1999:blog-8574118689743302986.post-2047845278457588827</id><published>2010-07-12T17:20:02.635+03:00</published><updated>2010-07-12T17:20:02.635+03:00</updated><title type='text'>You could also use FastDateFormat in org.apache.co...</title><content type='html'>You could also use FastDateFormat in org.apache.commons.lang.time&lt;br /&gt;&lt;br /&gt;&amp;quot;FastDateFormat is a fast and thread-safe version of SimpleDateFormat&amp;quot;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574118689743302986/3404210907888313321/comments/default/2047845278457588827'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574118689743302986/3404210907888313321/comments/default/2047845278457588827'/><link rel='alternate' type='text/html' href='http://www.javacodegeeks.com/2010/07/java-best-practices-dateformat-in.html?showComment=1278944402635#c2047845278457588827' title=''/><author><name>Alain</name><uri>http://www.blogger.com/profile/09184543812434275012</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.javacodegeeks.com/2010/07/java-best-practices-dateformat-in.html' ref='tag:blogger.com,1999:blog-8574118689743302986.post-3404210907888313321' source='http://www.blogger.com/feeds/8574118689743302986/posts/default/3404210907888313321' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1514067791'/></entry><entry><id>tag:blogger.com,1999:blog-8574118689743302986.post-3154185703883958080</id><published>2010-07-12T15:42:12.147+03:00</published><updated>2010-07-12T15:42:12.147+03:00</updated><title type='text'>Hi Just!
Thanks for a clear explanation and perfor...</title><content type='html'>Hi Just!&lt;br /&gt;Thanks for a clear explanation and performance results. &lt;br /&gt;One thing to mention: your solution holds all he created DateFormat instances s in memory, never freeing them. I can suggest solution for this problem:&lt;br /&gt;http://asolntsev.blogspot.com/2009/05/threadsafedateformat.html</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8574118689743302986/3404210907888313321/comments/default/3154185703883958080'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8574118689743302986/3404210907888313321/comments/default/3154185703883958080'/><link rel='alternate' type='text/html' href='http://www.javacodegeeks.com/2010/07/java-best-practices-dateformat-in.html?showComment=1278938532147#c3154185703883958080' title=''/><author><name>asolntsev</name><uri>http://www.blogger.com/profile/16632087166612261207</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp0.blogger.com/_KH5QVrOFzeM/R6wTJvp8TkI/AAAAAAAAAfk/8pQI3aFpLew/S220/grease_msn.JPG'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.javacodegeeks.com/2010/07/java-best-practices-dateformat-in.html' ref='tag:blogger.com,1999:blog-8574118689743302986.post-3404210907888313321' source='http://www.blogger.com/feeds/8574118689743302986/posts/default/3404210907888313321' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1804344762'/></entry></feed>
