Java Best Practices – DateFormat in a Multithreading Environment

Discussions

News: Java Best Practices – DateFormat in a Multithreading Environment

  1. This is the first of a series of articles concerning proposed practices while working with the Java programming language. In this article we are going to discuss about the problems one may face when working with the DateFormat class in a multithreaded environment. Additionally we are going to discuss how to properly utilize the DateFormat class to achieve ultra high performance when parsing and formatting dates.

    Read more at :

    Java Code Geeks: Java Best Practices – DateFormat in a Multithreading Environment

  2. Why not...[ Go to top ]

    use Joda date and not even think about the probem

  3. Why not...[ Go to top ]

    Hello Time,

    Can you please provide relevant performance results while using Joda date in a multithreading environment?

    Comparing the ThreadLocal approach with Joda date in terms of performance should help us deside the best way to go!

    BRs

  4. @Override
    public DateFormat get() {
    return super.get();
    }

    @Override
    public void remove() {
    super.remove();
    }

    @Override
    public void set(DateFormat value) {
    super.set(value);
    }

    Since when is this a 'best practice'?

  5. Hello James,

    You are absolutely right, the three designated methods can be omitted of course! since we only invoke super() methods.

    Nevertheless, your comment about "best practice" being based on the specific part of the article forces me to believe that you didn't get the point of the "best practice" statement at all.

    BRs

    Justin

  6. Nevertheless, your comment about "best practice" being based on the specific part of the article forces me to believe that you didn't get the point of the "best practice" statement at all.

    The article overall was fine but pretty basic.  But maybe there's a need to reiterate this kind of thing every few years.

    If someone is getting something out of your article, then they may not know which parts are unecessary.  Your target audience isn't really the people who already know all of this stuff.  I think you should be careful to not include cruft in your examples.

  7. Hi all, I also currently use Joda Time to get around this and other issues with Date and Calendar. In fact the creator of Joda Time (Stephen Colebourne) and Michael Nascimento Santos are the spec leads for the new Date and Time APIs for Java 7 (JSR-310). Ben Evans and I are in the process of writing "The Well Grounded Java 7 Developer" and so I've been working a little with the new JSR-310 and was pleased to see that the core representations of date and time are immutable and that there is a theme of thread safety throughout. If you're interested in ensuring that we have a better date and time future in core Java then Stephen et al could do with more developers helping them out to ensure that JSR-310 makes it on time for Java 7. It's actually really easy to get the latest source/binary to experiment on, you can follow the instructions starting from https://jsr-310.dev.java.net/ Cheers, Martijn