diff --git a/grails-app/services/au/org/ala/ecodata/ParatooService.groovy b/grails-app/services/au/org/ala/ecodata/ParatooService.groovy index 699c72c5f..0491b6ac1 100644 --- a/grails-app/services/au/org/ala/ecodata/ParatooService.groovy +++ b/grails-app/services/au/org/ala/ecodata/ParatooService.groovy @@ -755,7 +755,7 @@ class ParatooService { dataSet.progress = Activity.PLANNED String dataSetName = buildName( paratooCollectionId.protocolId, - DateUtil.formatAsDisplayDate(paratooCollectionId.eventTime), project) + DateUtil.formatAsDisplayDateTime(paratooCollectionId.eventTime), project) dataSet.name = dataSetName dataSet diff --git a/src/main/groovy/au/org/ala/ecodata/DateUtil.groovy b/src/main/groovy/au/org/ala/ecodata/DateUtil.groovy index 97fa67bc4..8c5831423 100644 --- a/src/main/groovy/au/org/ala/ecodata/DateUtil.groovy +++ b/src/main/groovy/au/org/ala/ecodata/DateUtil.groovy @@ -23,6 +23,7 @@ class DateUtil { static DateTimeFormatter ISO_DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'") static DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd") + static DateTimeFormatter DISPLAY_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd h:mm a") static Date parse(String dateStr) { SimpleDateFormat format = new SimpleDateFormat(dateFormat) return format.parse(dateStr.replace("Z", "+0000")) @@ -48,6 +49,11 @@ class DateUtil { dateTime.format(DATE_FORMATTER) } + static String formatAsDisplayDateTime(Date date) { + ZonedDateTime dateTime = ZonedDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault()) + dateTime.format(DISPLAY_DATE_TIME_FORMATTER) + } + /** * Returns a formatted string representing the financial year a report or activity falls into, based on * the end date. This method won't necessarily work for start dates as it will subtract a day from the value diff --git a/src/test/groovy/au/org/ala/ecodata/ParatooServiceSpec.groovy b/src/test/groovy/au/org/ala/ecodata/ParatooServiceSpec.groovy index f17761fd9..a2911ce00 100644 --- a/src/test/groovy/au/org/ala/ecodata/ParatooServiceSpec.groovy +++ b/src/test/groovy/au/org/ala/ecodata/ParatooServiceSpec.groovy @@ -156,7 +156,7 @@ class ParatooServiceSpec extends MongoSpec implements ServiceUnitTest