diff options
Diffstat (limited to 'sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapperHelper.java')
-rw-r--r-- | sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapperHelper.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapperHelper.java b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapperHelper.java index f443fd615..d468e075c 100644 --- a/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapperHelper.java +++ b/sdnr/wt/common-yang/utils/src/main/java/org/onap/ccsdk/features/sdnr/wt/yang/mapper/YangToolsMapperHelper.java @@ -278,6 +278,12 @@ public class YangToolsMapperHelper { return notification instanceof DOMEvent; } + /** + * Get time instant from notification if available or default + * @param notification + * @param defaultValue + * @return DateAndTime + */ public static DateAndTime getTime(Notification notification, Instant defaultValue) { Instant time; if (hasTime(notification)) { // If notification class extends/implements the EventInstantAware @@ -290,6 +296,21 @@ public class YangToolsMapperHelper { return DateAndTime.getDefaultInstance(ZonedDateTime.ofInstant(time, ZoneOffset.UTC).format(formatterOutput)); } + /** + * Get time instant from notification if available or actual time + * @param notification + * @return DateAndTime + */ + public static DateAndTime getTime(Notification notification) { + return getTime(notification, Instant.now()); + } + + /** + * Get time instant from DOM notification if available or default + * @param DOM notification + * @param defaultValue + * @return DateAndTime + */ public static DateAndTime getTime(DOMNotification notification, Instant defaultValue) { Instant time; if (hasTime(notification)) { // If notification class extends/implements the EventInstantAware @@ -301,4 +322,13 @@ public class YangToolsMapperHelper { } return DateAndTime.getDefaultInstance(ZonedDateTime.ofInstant(time, ZoneOffset.UTC).format(formatterOutput)); } + + /** + * Get time instant from notification if available or actual time + * @param DOM notification + * @return DateAndTime + */ + public static DateAndTime getTime(DOMNotification notification) { + return getTime(notification, Instant.now()); + } } |