Java SQL Time Calculate getNewFileList(String path, String mintime)

Here you can find the source of getNewFileList(String path, String mintime)

Description

get New File List

License

Apache License

Declaration

public static List getNewFileList(String path, String mintime) throws ParseException 

Method Source Code


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

import java.io.File;
import java.text.ParseException;
import java.util.Date;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static List getNewFileList(String path, String mintime) throws ParseException {

        List list = new ArrayList();

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        Date d;//w  w w  . j av a 2  s . c  om
        d = sdf.parse(mintime);

        List<String> filelist = getAllFileName(path);
        for (String file : filelist) {
            File f = new File(file);
            //Date filetime = new Date(f.lastModified());
            Timestamp time = new Timestamp(f.lastModified());
            //SimpleDateFormat sdt = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
            //String dt = sdt.format(filetime);
            if (d.getTime() < time.getTime()) {
                /*//System.out.println(mintime + "======" + mintime);
                System.out.println("--------------------------------------");
                System.out.println(file + "======" + time);*/
                list.add(file);
            }
        }
        return list;
    }

    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. getExpiresTime(Long validityPeriod)
  2. getMidNightTime()
  3. getMinute(Time time)
  4. getMonth(String dateTime)
  5. getMonth(String dateTime)
  6. getNextDateTimeStr(String format)
  7. getNurseCoverageEndTime(Time startTime, Time shiftLength)
  8. getPreviousDateTimeString(String format)