2 * ============LICENSE_START========================================================================
3 * ONAP : ccsdk feature sdnr wt
4 * =================================================================================================
5 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6 * =================================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software distributed under the License
13 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14 * or implied. See the License for the specific language governing permissions and limitations under
16 * ============LICENSE_END==========================================================================
18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.NetconfTimeStamp;
22 import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl;
23 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
26 * Converts time stamps into internal format according to ONF1.2 and ISO 8601.
27 * To be replaced by NetconfTimeStampImpl
30 public class InternalDateAndTime {
32 private static final String TESTPATTERNSTRING = "2017-01-01T00:00:00.0Z";
33 private static final String INITIALPATTERN = "0000-00-00T00:00:00.0Z";
35 private static final InternalDateAndTime TESTPATTERN = new InternalDateAndTime(TESTPATTERNSTRING);
36 private static final DateAndTime TESTPATTERN2 = new DateAndTime(TESTPATTERNSTRING);
38 private static final NetconfTimeStamp NETCONFTIME_CONVERTER = NetconfTimeStampImpl.getConverter();
40 /** Internal variable to hold the value, that is converted **/
41 private final String internalDateAndTime;
44 * Static builder ONF1.0
45 * @param time in ONF1.0 yang format
46 * @return InternalDateAndTime
49 public static InternalDateAndTime valueOf(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime time) {
50 return new InternalDateAndTime(time);
54 * @return Getter with String representation
56 public String getValue() {
57 return internalDateAndTime;
64 public static InternalDateAndTime getTestpattern() {
69 * @return DateAndTime testpattern
71 public static @Nullable DateAndTime getTestpatternDateAndTime() {
75 /*----------------------------------------------------------------
76 * Private constructors
80 * Convert ONF 1.2 DateAndTime to String
81 * @param time as input
83 private InternalDateAndTime(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime time) {
85 internalDateAndTime = NETCONFTIME_CONVERTER.getTimeStampFromNetconf(time.getValue());
87 internalDateAndTime = INITIALPATTERN;
93 * @param internalDateAndTime
95 private InternalDateAndTime(String internalDateAndTime) {
96 this.internalDateAndTime = internalDateAndTime;