Skip to content
Snippets Groups Projects
Commit 8bfb162d authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Added possibility to set exact date, for testing purposes

parent febbcb3e
No related branches found
No related tags found
No related merge requests found
...@@ -19,8 +19,12 @@ ...@@ -19,8 +19,12 @@
package no.nibio.vips.logic.util; package no.nibio.vips.logic.util;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
/** /**
* Provides a single entry point to system time. This is to be able to * Provides a single entry point to system time. This is to be able to
...@@ -43,7 +47,8 @@ public final class SystemTime { ...@@ -43,7 +47,8 @@ public final class SystemTime {
} }
cal.setTime(new Date()); cal.setTime(new Date());
cal.add(Calendar.MONTH, SYSTEM_TIME_OFFSET_MONTHS); cal.add(Calendar.MONTH, SYSTEM_TIME_OFFSET_MONTHS);
return cal.getTime();
return getExactDate() != null ? getExactDate(): cal.getTime();
} }
private static Integer getOffsetMonths() private static Integer getOffsetMonths()
...@@ -51,4 +56,23 @@ public final class SystemTime { ...@@ -51,4 +56,23 @@ public final class SystemTime {
return Integer.valueOf(System.getProperty("no.nibio.vips.logic.SYSTEM_TIME_OFFSET_MONTHS")); return Integer.valueOf(System.getProperty("no.nibio.vips.logic.SYSTEM_TIME_OFFSET_MONTHS"));
} }
private static Date getExactDate()
{
String dateStr = System.getProperty("no.nibio.vips.logic.SYSTEM_TIME_EXACT_DATE");
if(dateStr != null)
{
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
try {
return format.parse(dateStr);
} catch (ParseException ex) {
Logger.getLogger(SystemTime.class.getName()).log(Level.SEVERE, null, ex);
return null;
}
}
else
{
return null;
}
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment