Package com.snowbound.common.utils
Class ThreadSafeDateFormatter
- java.lang.Object
-
- com.snowbound.common.utils.ThreadSafeDateFormatter
-
public class ThreadSafeDateFormatter extends java.lang.ObjectClass for formatting Date objects in a thread-safe manner.
-
-
Constructor Summary
Constructors Constructor Description ThreadSafeDateFormatter()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Stringformat(java.text.DateFormat dateFormat, java.util.Date date)This class / method exists because DateFormats are notoriously not thread safe.static java.util.Dateparse(java.text.DateFormat dateFormat, java.lang.String dateString)This class / method exists because DateFormats are notoriously not thread safe.
-
-
-
Method Detail
-
format
public static java.lang.String format(java.text.DateFormat dateFormat, java.util.Date date)This class / method exists because DateFormats are notoriously not thread safe. This method ensures thread safety of formatting a date.- Parameters:
dateFormat- Date format to usedate- Date to format- Returns:
- Formatted date
-
parse
public static java.util.Date parse(java.text.DateFormat dateFormat, java.lang.String dateString) throws java.text.ParseExceptionThis class / method exists because DateFormats are notoriously not thread safe. This method ensures thread safety of parsing a date.- Parameters:
dateFormat- Date format to usedateString- String to parse- Returns:
- Date parsed from string
- Throws:
java.text.ParseException- if provided string is not parseable
-
-