On Thu, 09 May 2013 11:10:14 +0200, Stephen Colebourne  
<scolebou...@joda.org> wrote:

> Joda-Time allows you to change the clock used by Joda-Time code, but
> not to change System.currentTimeMillis(). So I don't think Joda-Time
> will overly help you.
> Stephen

My personal take on this is that mocking System.currentTimeMillis() is  
partially possible, as described in the linked blog post, but it's too  
cumbersome and doesn't give me a feeling of stable enough tests. Thus my  
approach is to have a TimeFactory (aka DateFactory) as in the post, or use  
the feature cited by Stephen. As the blog post says, there are still  
troubles if you use third party libraries that do call  
System.currentTimeMillis(). My approach is just to avoid them, or avoid  
the parts that use it such as @Past - so far I've been able to, but I  
understand it's a very context-dependent situation.


-- 
Fabrizio Giudici - Java Architect @ Tidalwave s.a.s.
"We make Java work. Everywhere."
http://tidalwave.it/fabrizio/blog - fabrizio.giud...@tidalwave.it

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and 
their applications. This 200-page book is written by three acclaimed 
leaders in the field. The early access version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
Joda-interest mailing list
Joda-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/joda-interest

Reply via email to