aboutsummaryrefslogtreecommitdiffstats
path: root/ajsc-aai/src/test/java/org/openecomp/aai/util/DbTestGetFileTime.java
diff options
context:
space:
mode:
Diffstat (limited to 'ajsc-aai/src/test/java/org/openecomp/aai/util/DbTestGetFileTime.java')
-rw-r--r--ajsc-aai/src/test/java/org/openecomp/aai/util/DbTestGetFileTime.java55
1 files changed, 55 insertions, 0 deletions
diff --git a/ajsc-aai/src/test/java/org/openecomp/aai/util/DbTestGetFileTime.java b/ajsc-aai/src/test/java/org/openecomp/aai/util/DbTestGetFileTime.java
new file mode 100644
index 0000000..d56a4d2
--- /dev/null
+++ b/ajsc-aai/src/test/java/org/openecomp/aai/util/DbTestGetFileTime.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.openecomp.aai
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.aai.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.attribute.BasicFileAttributeView;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.nio.file.attribute.FileTime;
+
+public class DbTestGetFileTime {
+
+
+ /**
+ * Creates the file return time.
+ *
+ * @param path the path
+ * @return the file time
+ * @throws IOException Signals that an I/O exception has occurred.
+ */
+ public FileTime createFileReturnTime( String path) throws IOException {
+ File file = new File(path);
+ if(!file.exists()) {
+ file.createNewFile();
+ }
+ Path p = Paths.get(file.getAbsolutePath());
+ BasicFileAttributes view
+ = Files.getFileAttributeView(p, BasicFileAttributeView.class)
+ .readAttributes();
+ FileTime fileTime=view.creationTime();
+ // also available view.lastAccessTine and view.lastModifiedTime
+ return fileTime;
+ }
+}