phet commented on code in PR #3747:
URL: https://github.com/apache/gobblin/pull/3747#discussion_r1299007078
##########
gobblin-service/src/main/java/org/apache/gobblin/service/modules/scheduler/GobblinServiceJobScheduler.java:
##########
@@ -467,6 +467,18 @@ protected static String
jobSchedulerTracePrefixBuilder(Properties jobProps) {
jobProps.getProperty(ConfigurationKeys.FLOW_GROUP_KEY, "<<no flow
group>>"));
}
+ /**
+ * Takes a given Date object and converts the timezone to UTC before
returning the number of millseconds since epoch
+ * @param date
+ */
+ public static long getMillisecondsSinceEpochInUTC(Date date) {
+ // Create a Calendar object and set it to the given Date
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(date);
+ calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
+ return calendar.getTimeInMillis();
+ }
Review Comment:
let's opt for the modern, Joda/`java.time` classes. I believe something
like:
```
ZonedDateTime.of(
LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault()),
ZoneOffset.UTC
).toInstant().toEpochMilli()
```
nit: this is not a accessor (`get`), but a conversion, so `asUTCEpochMillis`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]