Java Today createTodayPrefixedDirectory(final String prefix, final File parent)

Here you can find the source of createTodayPrefixedDirectory(final String prefix, final File parent)

Description

Creates the today prefixed directory.

License

Open Source License

Parameter

Parameter Description
prefix the prefix
parent the parent

Return

the file

Declaration

public static File createTodayPrefixedDirectory(final String prefix, final File parent) 

Method Source Code


//package com.java2s;
/* (c) 2014 Open Source Geospatial Foundation - all rights reserved
 * This code is licensed under the GPL 2.0 license, available at the root
 * application directory.//www  . j ava2 s .c  o m
 */

import java.io.File;

import java.text.SimpleDateFormat;
import java.util.Date;

public class Main {
    /**
     * Creates the today prefixed directory.
     *
     * @param prefix
     *            the prefix
     * @param parent
     *            the parent
     * @return the file
     */
    public static File createTodayPrefixedDirectory(final String prefix, final File parent) {
        final SimpleDateFormat SDF_HMS = new SimpleDateFormat("yyyy_MM_dd_hhmmsss");
        final String newPath = (new StringBuffer(parent.getAbsolutePath().trim()).append(File.separatorChar)
                .append(prefix).append(File.separatorChar).append(SDF_HMS.format(new Date()))).toString();
        File dir = new File(newPath);
        if (!dir.exists()) {
            dir.mkdirs();
        }

        return dir;
    }
}

Related

  1. afterToday(String date)
  2. beforeToday(int days)
  3. converTimeToDayStartEnd(long time, long[] out)
  4. createTodayDirectory(File destDir)
  5. createTodayDirectory(File destDir, String inputFileName)
  6. deletePreviousDay(Calendar today, String temppath)
  7. endOfToday()
  8. formatToday()
  9. formatToday()