Java Timestamp Create getTimestampedPNGFile(File saveDir)

Here you can find the source of getTimestampedPNGFile(File saveDir)

Description

get Timestamped PNG File

License

Open Source License

Declaration

private static File getTimestampedPNGFile(File saveDir) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.File;

import java.text.DateFormat;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss");

    private static File getTimestampedPNGFile(File saveDir) {
        String s = DATE_FORMAT.format(new Date()).toString();
        int i = 1;
        while (true) {
            File file1 = new File(saveDir, s + (i == 1 ? "" : "_" + i) + ".png");
            if (!file1.exists()) {
                return file1;
            }/*from  ww  w. j  a v a 2s  .co m*/
            ++i;
        }
    }
}

Related

  1. getTimeStampByFormat(String style)
  2. getTimestampDate(long timestamp)
  3. getTimestampDate(Timestamp ts)
  4. getTimestampDateDotTime()
  5. getTimestampDiff(int n)
  6. getTimestampedVideoFileName()
  7. getTimestampFormat()
  8. getTimestampFormat()
  9. getTimestampFormat()