Capture the file creation date

0

BoEstou creating a control panel in jsp to show the excell file updates of a particular network folder.

Problem: I have several programs in SAS that are scheduled to update daily, and generate the files in the folder. But sometimes the programming does not run and the file is outdated.

Purpose: Identify everything that is not up to date and run the program manually.

The idea I had is to use this formula but I do not know how to capture the date of the file in jsp:

Se dt_arquivo = hoje() campo recebe "Atualizado" senão "Não "Atualizado"
    
asked by anonymous 24.01.2018 / 13:13

1 answer

0

Create a method and save saved information in the database:

public InformacaoArquivo  verificarDataModificacao(String nomeArquivo) throws IOException {
         Path file  =  new File("C:\text\"+nomeArquivo).toPath();
         BasicFileAttributes attr = Files.readAttributes(file, BasicFileAttributes.class);

         InformacaoArquivo info = new InformacaoArquivo(attr.creationTime().toString(), attr.lastAccessTime().toString(), attr.lastModifiedTime().toString() ); 

         System.out.println("hora de criação: " + attr.creationTime());
         System.out.println("último  acesso: " + attr.lastAccessTime());
         System.out.println("última  modifição: " + attr.lastModifiedTime());
        return info;     
    }


public class InformacaoArquivo {

  private String horaCriacao;
  private String ultimoAcesso;
  private String  ultimaModificao;

  public InformacaoArquivo(String horaCriacao, String ultimoAcesso, String ultimaModificao) {
      this.horaCriacao = horaCriacao;
      this.ultimoAcesso = ultimoAcesso;
      this.ultimaModificao = ultimaModificao;
}

You can use in a class and call in your jsp or if you see yourself using a controller you can do it as well and go to jsp

Then you can convert the date to Date and compare it. all amounts must be in the java.nio.* package;

    
24.01.2018 / 14:30