Skip to content
Snippets Groups Projects
Commit f69dc6c1 authored by jakubs's avatar jakubs
Browse files

SSDM-3474: improve generation of unique timestampts

SVN: 36095
parent 5b280fed
No related branches found
No related tags found
No related merge requests found
......@@ -44,6 +44,7 @@ import java.util.Arrays;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Pattern;
import org.apache.commons.io.FileUtils;
......@@ -1401,21 +1402,19 @@ public final class FileUtilities
return new File(uniqueFilePath);
}
private static AtomicInteger uniqueIncrement = new AtomicInteger();
/**
* @return
* The format of the unique string consists of a time stamp and a unique random number:
* <var>_yyyy_MM_dd_HH_mm_ss_SSS_</var> + unique_number
* @return The format of the unique string consists of a time stamp and a unique number: <var>_yyyy_MM_dd_HH_mm_ss_SSS_</var> + unique_number
*/
public final static String getUniqueTimestamp()
{
final String DATE_FORMAT = "_yyyy_MM_dd_HH_mm_ss_SSS_";
int random_int = (int) (Math.random() * 1000);
long timestamp = System.currentTimeMillis();
Date date = new Date(timestamp);
DateFormat formatter = new SimpleDateFormat(DATE_FORMAT);
return formatter.format(date) + random_int;
return formatter.format(date) + uniqueIncrement;
}
......
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