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. To be replaced by NetconfTimeStampImpl
29 public class InternalDateAndTime {
31 private static final String TESTPATTERNSTRING = "2017-01-01T00:00:00.0Z";
32 private static final String INITIALPATTERN = "0000-00-00T00:00:00.0Z";
34 private static final InternalDateAndTime TESTPATTERN = new InternalDateAndTime(TESTPATTERNSTRING);
35 private static final DateAndTime TESTPATTERN2 = new DateAndTime(TESTPATTERNSTRING);
37 private static final NetconfTimeStamp NETCONFTIME_CONVERTER = NetconfTimeStampImpl.getConverter();
39 /** Internal variable to hold the value, that is converted **/
40 private final String internalDateAndTime;
43 * Static builder ONF1.0
45 * @param time in ONF1.0 yang format
46 * @return InternalDateAndTime
49 public static InternalDateAndTime valueOf(
50 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime time) {
51 return new InternalDateAndTime(time);
55 * @return Getter with String representation
57 public String getValue() {
58 return internalDateAndTime;
66 public static InternalDateAndTime getTestpattern() {
71 * @return DateAndTime testpattern
73 public static @Nullable DateAndTime getTestpatternDateAndTime() {
77 /*----------------------------------------------------------------
78 * Private constructors
82 * Convert ONF 1.2 DateAndTime to String
84 * @param time as input
86 private InternalDateAndTime(
87 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime time) {
89 internalDateAndTime = NETCONFTIME_CONVERTER.getTimeStampFromNetconf(time.getValue());
91 internalDateAndTime = INITIALPATTERN;
98 * @param internalDateAndTime
100 private InternalDateAndTime(String internalDateAndTime) {
101 this.internalDateAndTime = internalDateAndTime;