{"id":300,"date":"2010-07-11T18:29:00","date_gmt":"2010-07-11T18:29:00","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/2012\/10\/java-best-practices-dateformat-in-a-multithreading-environment.html"},"modified":"2012-10-21T19:17:07","modified_gmt":"2012-10-21T19:17:07","slug":"java-best-practices-dateformat-in","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-dateformat-in.html","title":{"rendered":"Java Best Practices \u2013 DateFormat in a Multithreading Environment"},"content":{"rendered":"<p>This is the first of a series of articles concerning proposed practices while working with the Java programming language.<\/p>\n<p>All discussed topics are based on use cases derived from the development of mission critical, ultra high performance production systems for the telecommunication industry.<\/p>\n<p>Prior reading each section of this article it is highly recommended that you consult the relevant Java API documentation for detailed information and code samples.<\/p>\n<p>All tests are performed against a Sony Vaio with the following characteristics :<\/p>\n<ul>\n<li>System : openSUSE 11.1 (x86_64)<\/li>\n<li>Processor (CPU) : Intel(R) Core(TM)2 Duo CPU T6670 @ 2.20GHz<\/li>\n<li>Processor Speed : 1,200.00 MHz<\/li>\n<li>Total memory (RAM) : 2.8 GB<\/li>\n<li>Java : OpenJDK 1.6.0_0 64-Bit<\/li>\n<\/ul>\n<p>The following test configuration is applied :<\/p>\n<ul>\n<li>Concurrent worker Threads : 200<\/li>\n<li>Test repeats per worker Thread : 1000<\/li>\n<li>Overall test runs : 100<\/li>\n<\/ul>\n<div><span style=\"font-size: large\"><br \/>\n<\/span><\/div>\n<div><span style=\"font-size: large\"><strong>Using DateFormat in a multithreading environment<\/strong><\/span><\/div>\n<p>Working with <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.4.2\/docs\/api\/java\/text\/DateFormat.html\">DateFormat<\/a> in a multithreading environment can be tricky. The Java API documentation clearly states :<\/p>\n<p>\u201c<i>Date formats are not synchronized. It is recommended to create separate format instances for each thread. If multiple threads access a format concurrently, it must be synchronized externally.<\/i>\u201d<\/p>\n<p>A typical case scenario is to convert a <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.4.2\/docs\/api\/java\/util\/Date.html\">Date<\/a> to its String representation or vice versa, using a predefined format. Creating new <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.4.2\/docs\/api\/java\/text\/DateFormat.html\">DateFormat<\/a> instances for every conversion is very inefficient. You should keep in mind that the static factory methods \u201cgetDateInstance(..)\u201d also create new <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.4.2\/docs\/api\/java\/text\/DateFormat.html\">DateFormat<\/a> instances when used. What most developers do is that they construct a <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.4.2\/docs\/api\/java\/text\/DateFormat.html\">DateFormat<\/a> instance, using a <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.4.2\/docs\/api\/java\/text\/DateFormat.html\">DateFormat<\/a> implementation class (e.g. <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.4.2\/docs\/api\/java\/text\/SimpleDateFormat.html\">SimpleDateFormat<\/a>), and assign its value to a class variable. The class scoped variable is used for all their <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.4.2\/docs\/api\/java\/util\/Date.html\">Date<\/a> parsing and formatting needs. The aforementioned approach, although very efficient, can cause problems when multiple threads access the same instance of the class variable, due to lack of synchronization on the <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.4.2\/docs\/api\/java\/text\/DateFormat.html\">DateFormat<\/a> class. Typical exceptions thrown when parsing to create a <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.4.2\/docs\/api\/java\/util\/Date.html\">Date<\/a> object are :<\/p>\n<ul>\n<li>java.lang.NumberFormatException<\/li>\n<li>java.lang.ArrayIndexOutOfBoundsException<\/li>\n<\/ul>\n<p>You should also experience malformed <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.4.2\/docs\/api\/java\/util\/Date.html\">Date<\/a> to String representation when formatting is performed.<\/p>\n<p>To properly handle the aforementioned issues, it is vital to clarify the architecture of your multithreading environment. The Java Virtual Machine allows an application to have multiple threads of execution running concurrently. Typically, in a multithreading environment (either a container inside the JVM or the JVM itself), <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.3\/docs\/api\/java\/lang\/Thread.html\">Thread<\/a> pooling should be performed. Worker threads should be constructed and initialized upon startup, utilized to execute your programs. For example a Web container constructs a pool of worker threads to serve all incoming traffic. <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.3\/docs\/api\/java\/lang\/Thread.html\">Thread<\/a> pooling is the most efficient way to manipulate system resources mainly due to the fact that <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.3\/docs\/api\/java\/lang\/Thread.html\">Thread<\/a> creation and initialization is a high resource consuming task for the Java Virtual Machine. Nevertheless application parallelism can be achieved by simply creating a new <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.3\/docs\/api\/java\/lang\/Thread.html\">Thread<\/a> of execution for every piece of code you want to be executed concurrently.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>Concerning class scoped <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.4.2\/docs\/api\/java\/text\/DateFormat.html\">DateFormat<\/a> instances :<\/p>\n<ul>\n<li>If you have clarified that <strong>NO<\/strong> <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.3\/docs\/api\/java\/lang\/Thread.html\">Thread<\/a> pools are used in your environment then only new <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.3\/docs\/api\/java\/lang\/Thread.html\">Thread<\/a> instances concurrently access your <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.4.2\/docs\/api\/java\/text\/DateFormat.html\">DateFormat<\/a> instance. In this case it is recommended to synchronize that <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.4.2\/docs\/api\/java\/text\/DateFormat.html\">DateFormat<\/a> instance externally<\/li>\n<li>In case <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.3\/docs\/api\/java\/lang\/Thread.html\">Thread<\/a> pools are used, there is a limited number of <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.3\/docs\/api\/java\/lang\/Thread.html\">Thread<\/a> instances that can access your <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.4.2\/docs\/api\/java\/text\/DateFormat.html\">DateFormat<\/a> instance concurrently. Thus it is recommended to create separate <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.4.2\/docs\/api\/java\/text\/DateFormat.html\">DateFormat<\/a> instances for each thread using the <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.4.2\/docs\/api\/java\/lang\/ThreadLocal.html\">ThreadLocal<\/a> approach<\/li>\n<\/ul>\n<p>Below are examples of \u201cgetDateInstance(..)\u201d, &#8220;synchronization&#8221; and <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.4.2\/docs\/api\/java\/lang\/ThreadLocal.html\">ThreadLocal<\/a> approaches :<\/p>\n<pre class=\"brush: java\">package com.javacodegeeks.test;\r\n\r\nimport java.text.DateFormat;\r\nimport java.text.ParseException;\r\nimport java.text.SimpleDateFormat;\r\nimport java.util.Date;\r\n\r\npublic class ConcurrentDateFormatAccess {\r\n\r\n public Date convertStringToDate(String dateString) throws ParseException {\r\n  return SimpleDateFormat.getDateInstance(DateFormat.MEDIUM).parse(dateString);\r\n }\r\n\r\n}\r\n<\/pre>\n<pre class=\"brush: java\">package com.javacodegeeks.test;\r\n\r\nimport java.text.DateFormat;\r\nimport java.text.ParseException;\r\nimport java.text.SimpleDateFormat;\r\nimport java.util.Date;\r\n\r\npublic class ConcurrentDateFormatAccess {\r\n\r\n private DateFormat df = new SimpleDateFormat(\"yyyy MM dd\");\r\n\r\n public Date convertStringToDate(String dateString) throws ParseException {\r\n  Date result;\r\n  synchronized(df) {\r\n   result = df.parse(dateString);\r\n  }\r\n  return result;\r\n }\r\n\r\n}\r\n<\/pre>\n<p>Things to notice here :<\/p>\n<ul>\n<li>Every individual <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.3\/docs\/api\/java\/lang\/Thread.html\">Thread<\/a> executing the \u201cconvertStringToDate\u201d operation, is trying to acquire the monitor lock on the <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.4.2\/docs\/api\/java\/text\/DateFormat.html\">DateFormat<\/a> Object prior acquiring a reference to the <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.4.2\/docs\/api\/java\/text\/DateFormat.html\">DateFormat<\/a> class variable instance . If another <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.3\/docs\/api\/java\/lang\/Thread.html\">Thread<\/a> is holding the lock then the current <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.3\/docs\/api\/java\/lang\/Thread.html\">Thread<\/a> waits until the lock is released. That way only one <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.3\/docs\/api\/java\/lang\/Thread.html\">Thread<\/a> is accessing the <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.4.2\/docs\/api\/java\/text\/DateFormat.html\">DateFormat<\/a> instance at a time<\/li>\n<\/ul>\n<ul><\/ul>\n<pre class=\"brush: java\">package com.javacodegeeks.test;\r\n\r\nimport java.text.DateFormat;\r\nimport java.text.ParseException;\r\nimport java.text.SimpleDateFormat;\r\nimport java.util.Date;\r\n\r\npublic class ConcurrentDateFormatAccess {\r\n\r\n private ThreadLocal&lt;DateFormat&gt; df = new ThreadLocal&lt;DateFormat&gt; () {\r\n\r\n  @Override\r\n  public DateFormat get() {\r\n   return super.get();\r\n  }\r\n\r\n  @Override\r\n  protected DateFormat initialValue() {\r\n   return new SimpleDateFormat(\"yyyy MM dd\");\r\n  }\r\n\r\n  @Override\r\n  public void remove() {\r\n   super.remove();\r\n  }\r\n\r\n  @Override\r\n  public void set(DateFormat value) {\r\n   super.set(value);\r\n  }\r\n\r\n };\r\n\r\n public Date convertStringToDate(String dateString) throws ParseException {\r\n  return df.get().parse(dateString);\r\n }\r\n\r\n}\r\n<\/pre>\n<p>Things to notice here :<\/p>\n<ul>\n<li>Every individual <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.3\/docs\/api\/java\/lang\/Thread.html\">Thread<\/a> executing the \u201cconvertStringToDate\u201d operation, invokes the \u201cdf.get()\u201d operation in order to initialize or retrieve an already initialized reference of its local scoped <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.4.2\/docs\/api\/java\/text\/DateFormat.html\">DateFormat<\/a> instance<\/li>\n<\/ul>\n<p>Below we present a performance comparison chart between the three aforementioned approaches (notice that we have tested the parsing functionality of the <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.4.2\/docs\/api\/java\/text\/DateFormat.html\">DateFormat<\/a> utility class. We convert a String representation of a date to its <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.4.2\/docs\/api\/java\/util\/Date.html\">Date<\/a> Object equivalent, according to a specific date format).<\/p>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/1.bp.blogspot.com\/_tWwHCKnIbjs\/TDndNvP6o4I\/AAAAAAAAAAQ\/lEUc81qwLqY\/s1600\/chart.png\"><img decoding=\"async\" border=\"0\" height=\"152\" src=\"http:\/\/1.bp.blogspot.com\/_tWwHCKnIbjs\/TDndNvP6o4I\/AAAAAAAAAAQ\/lEUc81qwLqY\/s400\/chart.png\" width=\"400\" \/><\/a><\/div>\n<p>The horizontal axis represents the number of test runs and the vertical axis the average transactions per second (TPS) for each test run. Thus higher values are better. As you can see by using <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.3\/docs\/api\/java\/lang\/Thread.html\">Thread<\/a> pools and the <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.4.2\/docs\/api\/java\/lang\/ThreadLocal.html\">ThreadLocal<\/a> approach you can achieve superior performance compared to the \u201csynchronization\u201d and the \u201cgetDateInstance(..)\u201d approaches.<\/p>\n<p>Lastly, let me pinpoint that using the <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.4.2\/docs\/api\/java\/lang\/ThreadLocal.html\">ThreadLocal<\/a> approach without <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.3\/docs\/api\/java\/lang\/Thread.html\">Thread<\/a> pools, is equivalent to using the \u201cgetDateInstance(..)\u201d approach due to the fact that every new <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.3\/docs\/api\/java\/lang\/Thread.html\">Thread<\/a> has to initialize its local <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.4.2\/docs\/api\/java\/text\/DateFormat.html\">DateFormat<\/a> instance prior using it, thus a new <a href=\"http:\/\/download.oracle.com\/docs\/cd\/E17476_01\/javase\/1.4.2\/docs\/api\/java\/text\/DateFormat.html\">DateFormat<\/a> instance will be created with every single execution.<\/p>\n<p>Happy Coding!<\/p>\n<p>Justin<\/p>\n<div style=\"margin-bottom: 0px;margin-left: 0px;margin-right: 0px;margin-top: 0px\"><strong><i>Related Articles :<\/i><\/strong><\/div>\n<ul>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-high-performance.html\">Java Best Practices \u2013 High performance Serialization<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/08\/java-best-practices-vector-arraylist.html\">Java Best Practices \u2013 Vector vs ArrayList vs HashSet<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/09\/string-performance-exact-string.html\">Java Best Practices \u2013 String performance and Exact String Matching<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/09\/java-best-practices-queue-battle-and.html\">Java Best Practices \u2013 Queue battle and the Linked ConcurrentHashMap<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/11\/java-best-practices-char-to-byte-and.html\">Java Best Practices \u2013 Char to Byte and Byte to Char conversions<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>This is the first of a series of articles concerning proposed practices while working with the Java programming language. All discussed topics are based on use cases derived from the development of mission critical, ultra high performance production systems for the telecommunication industry. Prior reading each section of this article it is highly recommended that &hellip;<\/p>\n","protected":false},"author":4,"featured_media":148,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[71,70,66,72],"class_list":["post-300","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-core-java","tag-date","tag-dateformat","tag-java-best-practices","tag-multithreading"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Java Best Practices \u2013 DateFormat in a Multithreading Environment - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"This is the first of a series of articles concerning proposed practices while working with the Java programming language. All discussed topics are based\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-dateformat-in.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java Best Practices \u2013 DateFormat in a Multithreading Environment - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"This is the first of a series of articles concerning proposed practices while working with the Java programming language. All discussed topics are based\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-dateformat-in.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2010-07-11T18:29:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-10-21T19:17:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/java-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Byron Kiourtzoglou\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Byron Kiourtzoglou\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/java-best-practices-dateformat-in.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/java-best-practices-dateformat-in.html\"},\"author\":{\"name\":\"Byron Kiourtzoglou\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/9c0c8d27141b068173953202dd9aebeb\"},\"headline\":\"Java Best Practices \u2013 DateFormat in a Multithreading Environment\",\"datePublished\":\"2010-07-11T18:29:00+00:00\",\"dateModified\":\"2012-10-21T19:17:07+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/java-best-practices-dateformat-in.html\"},\"wordCount\":839,\"commentCount\":10,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/java-best-practices-dateformat-in.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/java-logo.jpg\",\"keywords\":[\"Date\",\"DateFormat\",\"Java Best Practices\",\"Multithreading\"],\"articleSection\":[\"Core Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/java-best-practices-dateformat-in.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/java-best-practices-dateformat-in.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/java-best-practices-dateformat-in.html\",\"name\":\"Java Best Practices \u2013 DateFormat in a Multithreading Environment - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/java-best-practices-dateformat-in.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/java-best-practices-dateformat-in.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/java-logo.jpg\",\"datePublished\":\"2010-07-11T18:29:00+00:00\",\"dateModified\":\"2012-10-21T19:17:07+00:00\",\"description\":\"This is the first of a series of articles concerning proposed practices while working with the Java programming language. All discussed topics are based\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/java-best-practices-dateformat-in.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/java-best-practices-dateformat-in.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/java-best-practices-dateformat-in.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/java-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/java-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2010\\\/07\\\/java-best-practices-dateformat-in.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Core Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/core-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Java Best Practices \u2013 DateFormat in a Multithreading Environment\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/9c0c8d27141b068173953202dd9aebeb\",\"name\":\"Byron Kiourtzoglou\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/45058c722c80f088c409be43e0f4be20dad81d55a7c9aefd75bab2e4253ae4e6?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/45058c722c80f088c409be43e0f4be20dad81d55a7c9aefd75bab2e4253ae4e6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/45058c722c80f088c409be43e0f4be20dad81d55a7c9aefd75bab2e4253ae4e6?s=96&d=mm&r=g\",\"caption\":\"Byron Kiourtzoglou\"},\"description\":\"Byron is a master software engineer working in the IT and Telecom domains. He is an applications developer in a wide variety of applications\\\/services. He is currently acting as the team leader and technical architect for a proprietary service creation and integration platform for both the IT and Telecom industries in addition to a in-house big data real-time analytics solution. He is always fascinated by SOA, middleware services and mobile development. Byron is co-founder and Executive Editor at Java Code Geeks.\",\"sameAs\":[\"https:\\\/\\\/www.pivotalgamers.com\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/byron-kiourtzoglou-530ab222\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/byron-kiourtzoglou\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Java Best Practices \u2013 DateFormat in a Multithreading Environment - Java Code Geeks","description":"This is the first of a series of articles concerning proposed practices while working with the Java programming language. All discussed topics are based","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-dateformat-in.html","og_locale":"en_US","og_type":"article","og_title":"Java Best Practices \u2013 DateFormat in a Multithreading Environment - Java Code Geeks","og_description":"This is the first of a series of articles concerning proposed practices while working with the Java programming language. All discussed topics are based","og_url":"https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-dateformat-in.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2010-07-11T18:29:00+00:00","article_modified_time":"2012-10-21T19:17:07+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/java-logo.jpg","type":"image\/jpeg"}],"author":"Byron Kiourtzoglou","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Byron Kiourtzoglou","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-dateformat-in.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-dateformat-in.html"},"author":{"name":"Byron Kiourtzoglou","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/9c0c8d27141b068173953202dd9aebeb"},"headline":"Java Best Practices \u2013 DateFormat in a Multithreading Environment","datePublished":"2010-07-11T18:29:00+00:00","dateModified":"2012-10-21T19:17:07+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-dateformat-in.html"},"wordCount":839,"commentCount":10,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-dateformat-in.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/java-logo.jpg","keywords":["Date","DateFormat","Java Best Practices","Multithreading"],"articleSection":["Core Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-dateformat-in.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-dateformat-in.html","url":"https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-dateformat-in.html","name":"Java Best Practices \u2013 DateFormat in a Multithreading Environment - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-dateformat-in.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-dateformat-in.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/java-logo.jpg","datePublished":"2010-07-11T18:29:00+00:00","dateModified":"2012-10-21T19:17:07+00:00","description":"This is the first of a series of articles concerning proposed practices while working with the Java programming language. All discussed topics are based","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-dateformat-in.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-dateformat-in.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-dateformat-in.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/java-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/java-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2010\/07\/java-best-practices-dateformat-in.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Core Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/core-java"},{"@type":"ListItem","position":4,"name":"Java Best Practices \u2013 DateFormat in a Multithreading Environment"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/9c0c8d27141b068173953202dd9aebeb","name":"Byron Kiourtzoglou","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/45058c722c80f088c409be43e0f4be20dad81d55a7c9aefd75bab2e4253ae4e6?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/45058c722c80f088c409be43e0f4be20dad81d55a7c9aefd75bab2e4253ae4e6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/45058c722c80f088c409be43e0f4be20dad81d55a7c9aefd75bab2e4253ae4e6?s=96&d=mm&r=g","caption":"Byron Kiourtzoglou"},"description":"Byron is a master software engineer working in the IT and Telecom domains. He is an applications developer in a wide variety of applications\/services. He is currently acting as the team leader and technical architect for a proprietary service creation and integration platform for both the IT and Telecom industries in addition to a in-house big data real-time analytics solution. He is always fascinated by SOA, middleware services and mobile development. Byron is co-founder and Executive Editor at Java Code Geeks.","sameAs":["https:\/\/www.pivotalgamers.com\/","https:\/\/www.linkedin.com\/in\/byron-kiourtzoglou-530ab222"],"url":"https:\/\/www.javacodegeeks.com\/author\/byron-kiourtzoglou"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/300","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=300"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/300\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/148"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=300"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=300"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=300"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}