Skip to content
Snippets Groups Projects
Commit b01eb0d2 authored by ribeaudc's avatar ribeaudc
Browse files

fix: - Bugs found by FindBugs.

SVN: 6261
parent 3e4bb4d8
No related merge requests found
......@@ -18,6 +18,7 @@ package ch.systemsx.cisd.bds;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.concurrent.atomic.AtomicReference;
/**
* Some constants used inside the <i>BDS</i> library
......@@ -34,7 +35,8 @@ public final class Constants
public final static char PATH_SEPARATOR = '/';
/** The uniformly date format used. */
public static final DateFormat DATE_FORMAT = new SimpleDateFormat(DATE_FORMAT_PATTERN);
public static final AtomicReference<DateFormat> DATE_FORMAT =
new AtomicReference<DateFormat>(new SimpleDateFormat(DATE_FORMAT_PATTERN));
private Constants()
{
......
......@@ -22,7 +22,6 @@ import java.util.Collections;
import java.util.Date;
import java.util.List;
import ch.systemsx.cisd.bds.exception.DataStructureException;
import ch.systemsx.cisd.bds.storage.IDirectory;
import ch.systemsx.cisd.common.collections.CollectionIO;
......@@ -203,7 +202,7 @@ public final class DataSet implements IStorable
folder.addKeyValuePair(CODE, code);
folder.addKeyValuePair(PRODUCTION_TIMESTAMP,
productionTimestamp == null ? StringUtils.EMPTY_STRING : Constants.DATE_FORMAT
.format(productionTimestamp));
.get().format(productionTimestamp));
folder.addKeyValuePair(PRODUCER_CODE, StringUtils.emptyIfNull(producerCode));
folder.addKeyValuePair(IS_MEASURED, Boolean.toString(isMeasured).toUpperCase());
folder.addKeyValuePair(OBSERVABLE_TYPE, observableTypeCode);
......
......@@ -61,7 +61,7 @@ public final class ExperimentRegistrationTimestamp implements IStorable
*/
public final void saveTo(final IDirectory directory)
{
directory.addKeyValuePair(FILE_NAME, Constants.DATE_FORMAT.format(date));
directory.addKeyValuePair(FILE_NAME, Constants.DATE_FORMAT.get().format(date));
}
//
......@@ -91,7 +91,7 @@ public final class ExperimentRegistrationTimestamp implements IStorable
@Override
public final String toString()
{
return Constants.DATE_FORMAT.format(date);
return Constants.DATE_FORMAT.get().format(date);
}
}
......@@ -189,7 +189,7 @@ public class Utilities
}
try
{
return Constants.DATE_FORMAT.parse(value);
return Constants.DATE_FORMAT.get().parse(value);
} catch (final ParseException ex)
{
throw new DataStructureException("Value of '" + name + "' version file is not a date: "
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment