Description: add support SOURCE_DATE_EPOCH
 See: https://reproducible-builds.org/specs/source-date-epoch/
Author: tony mancill <tmancill@debian.org>
Last-Update: 2017-08-13

--- a/src/org/mangosdk/spi/processor/Persistence.java
+++ b/src/org/mangosdk/spi/processor/Persistence.java
@@ -132,7 +132,7 @@
 		Writer writer = output.openWriter();
 		try {
 			writer.write("# Generated by " + name + "\n");
-			writer.write("# " + new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z", Locale.US).format(new Date()) + "\n");
+			writer.write("# " + new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z", Locale.US).format(getBuildDate()) + "\n");
 			writer.write(value);
 		}
 		finally {
@@ -144,4 +144,17 @@
 			}
 		}
 	}
+
+	// return build timestamp, either the value of SOURCE_DATE_EPOCH 
+	// in milliseconds or the current system time in milliseconds
+	// see: https://reproducible-builds.org/specs/source-date-epoch/
+	private long getBuildDate() {
+		try {
+			return Long.valueOf(System.getenv("SOURCE_DATE_EPOCH")) * 1000L;
+		}
+		catch (Exception e) {
+			// ignore any problems retrieving or casting SOURCE_DATE_EPOCH
+		}
+		return System.currentTimeMillis();
+	}
 }
