I heard about Joda Time a couple months back, but finally got to use and implement it in a project.
We all know the whole Java date thing is ugly, and I sure most people have the own "implementations" and extensions like Period objects and utility Date Diff classes. I know I've written my fair share over the years. I won't be doing that again...
I am not going to go into too much detail as the Joda documentation is pretty good.
I just wanna highlight some of the very usual functionality that won me over:
Setting the "System" time, very useful. The financial systems I have worked on throughout my career always had some concept that required the "Current Date" mostly for data and rules with effective date periods.
Joda lets you statically set the "Current Date" making it a pleasure to test with, ensuring that any new DateTime objects used will be based off the set date:
The classic Date diff:
Working with "parts", just the date or the time:
Sunday, January 9, 2011
Joda Time == Good Times
Labels: Joda Time
Subscribe to: Post Comments (Atom)
I have recently been slacking on content on my blog, between long stressful hours at work and to the wonderful toy that is an iPhone, I have...
I make no claim to be a "computer scientist" or a software "engineer", those titles alone can spark some debate, I regar...
I saw an article (well more of a rant) the other day, by Rob Williams Brain Drain in enterprise Dev . I have to say, I do agree with some o...
This series of posts will be about me getting to grips with JBoss Drools . The reasoning behind it is: SAP bought out my company's curre...
I recently finished 97 Things every programmer should know . Well to be completely honest I did skim over a couple of the 97, but all and al...
I see a lot of static method invocations there - how thread safe would Hours.hoursIn() be in, say a super fast paced transactional processing environment for say, a financial institution?ReplyDelete
Are you going to have to make complicated thread local factories to prevent race conditions (say in a web service class that called a moer of a lot)?
:) This exactly is why you use open source and don't write your own "implementations" ...ReplyDelete
To quote the Joda Time Documents:
"Hours is thread-safe and immutable."
Every public class in Joda-Time is documented as being thread-safe or not. Joda-Time makes heavy use of the immutability design pattern, and all immutable classes in Joda-Time are thread-safe. Many mutable classes whose instances are not likely to be shared are not thread-safe, and are documented as such.
The most common multi-threading mistake made by Java programmers is in the use of SimpleDateFormat. Calling its format method on a shared instance by concurrent threads can produce bizarre results. All of Joda-Time's formatting classes are thread-safe and immutable. "
Mua vé máy bay tại Aivivu, tham khảoReplyDelete
Ve may bay di My
ve may bay từ mỹ về việt nam hãng eva
giá vé máy bay từ đức về việt nam
các chuyến bay từ nga về việt nam
chuyến bay từ anh về việt nam
chuyến bay từ paris về hà nội
chi phi ve may bay cho chuyen gia nuoc ngoai