* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
package org.onap.dmaap.dbcapi.util;
-import java.util.Calendar;
-import java.util.Date;
-
import javax.xml.bind.annotation.XmlRootElement;
-
-import org.apache.log4j.Logger;
+import java.util.Date;
@XmlRootElement
public class DmaapTimestamp {
- static final Logger logger = Logger.getLogger(DmaapTimestamp.class);
- private static Calendar cal = Calendar.getInstance();
- private Date stamp;
-
- public DmaapTimestamp() {
-
- stamp = cal.getTime();
- logger.info("constructor: set val to " + stamp);
- }
-
- public void mark() {
- stamp = cal.getTime();
- logger.info("mark: set val to " + stamp);
- }
-
- public Date getVal() {
- return stamp;
- }
+ private Date stamp;
+
+ public DmaapTimestamp() {
+ this(new Date());
+ }
+
+ DmaapTimestamp(Date stamp) {
+ this.stamp = new Date(stamp.getTime());
+ }
+
+ public void mark() {
+ stamp = new Date();
+ }
+
+ public Date getVal() {
+ return new Date(stamp.getTime());
+ }
}