Skip to content

piotrl/jvm-simpledateformat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

JVM SimpleDateFormat Kata

Challange

  • Make SimpleDateFormat produce wrong results on multiple threads
  • Create Thread safe SimpleDateFormat

HowTo run

mvn exec:java

Results

SimpleDateFormat without thrad safe checks
[ERROR] SimpleDateFormat thrown exception: java.util.concurrent.ExecutionException: java.lang.NumberFormatException: multiple points

ThreadSafe formatter
[OK] All dates are the same

Solution

  • Creating ThreadLocal instance with SimpleDateFormat
ThreadLocal<DateFormat> threadDateFormat = ThreadLocal.withInitial(() -> new SimpleDateFormat(pattern));

About

Goal: Create thread safe instance of SimpleDateFormat

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages