Java SQL Time getMaxModifyTime(String path)

Here you can find the source of getMaxModifyTime(String path)

Description

get Max Modify Time

License

Apache License

Declaration

public static Timestamp getMaxModifyTime(String path) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.File;

import java.sql.Timestamp;

import java.util.ArrayList;
import java.util.List;

public class Main {

    public static Timestamp getMaxModifyTime(String path) {
        List<String> filelist = getAllFileName(path);
        Timestamp time = null;/*from  w w w  .ja v a2s.  c o  m*/

        for (String s : filelist) {
            File f = new File(s);
            if (time == null) {
                time = new Timestamp(f.lastModified());
            } else {
                if (time.getTime() < new Timestamp(f.lastModified()).getTime()) {
                    time = new Timestamp(f.lastModified());
                }
            }
        }
        return time;

    }

    public static List<String> getAllFileName(String path) {
        File file = new File(path);
        File[] fileName = file.listFiles();
        List<String> list = new ArrayList<>();
        if (file.isDirectory()) {
            for (File string : fileName)
                if (new File(string.getPath()).isFile()) {
                    System.out.println(string.getPath());
                    list.add(string.getPath());
                }
        } else {
            System.out.println("it's a file.");
            //System.exit(1);
        }
        return list;
    }
}

Related

  1. getFutureTime(int month)
  2. getGrandfatheredTime()
  3. getIntervalDays(Date time1, Date time2)
  4. getJoinedSysDateTime()
  5. getLastTimeOfDay(Calendar calendar)
  6. getMaxPollTime(final Connection jdbcConnection, final String tableName)
  7. getServerTime()
  8. getServerTimezone(Properties dbSettings)
  9. getSGWDateTime(long dateTime)