Skip to content
Snippets Groups Projects
Commit 4b926432 authored by Spark Fountain's avatar Spark Fountain
Browse files

improved snapshot folder naming with leading zeros

parent 76d1ee85
Branches
No related tags found
No related merge requests found
...@@ -181,11 +181,41 @@ public abstract class AbstractNode extends UntypedActor implements Serializable ...@@ -181,11 +181,41 @@ public abstract class AbstractNode extends UntypedActor implements Serializable
* @return Array[snapshot folder name, path to snapshot include filename] * @return Array[snapshot folder name, path to snapshot include filename]
*/ */
private String[] getSnapshotDirAndFilename(String name, LocalDateTime time) { private String[] getSnapshotDirAndFilename(String name, LocalDateTime time) {
String folder = time.getYear() + "-" + time.getMonthValue() + "-" + time.getDayOfMonth() + " " + String folder = getFolderName(time);
time.getHour() + "." + time.getMinute() + "." + time.getSecond();
return new String[]{folder, "snapshots/" + folder + "/" + name + ".json"}; return new String[]{folder, "snapshots/" + folder + "/" + name + ".json"};
} }
private String getFolderName(LocalDateTime time) {
String result = "";
String year = String.valueOf(time.getYear());
String month = String.valueOf(time.getMonthValue());
if(month.length()==1) {
month = "0" + month;
}
String day = String.valueOf(time.getDayOfMonth());
if(day.length()==1) {
day = "0" + day;
}
String hour = String.valueOf(time.getHour());
if(hour.length()==1) {
hour = "0" + day;
}
String minute = String.valueOf(time.getMinute());
if(minute.length()==1) {
minute = "0" + minute;
}
String second = String.valueOf(time.getSecond());
if(second.length()==1) {
second = "0" + second;
}
result = year + "-" + month + "-" + day + "_"
+ hour + "-" + minute + "-" + second;
return result;
}
private Statistics statistics = new Statistics(); private Statistics statistics = new Statistics();
public Statistics getStatistics() { public Statistics getStatistics() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment