Java Today createTodayDirectory(File destDir)

Here you can find the source of createTodayDirectory(File destDir)

Description

Create a subDirectory having the actual date as name, within a specified destination directory.

License

Open Source License

Parameter

Parameter Description
destDir the destination directory where to build the "today" directory.

Return

the created directory.

Declaration

public static File createTodayDirectory(File destDir) 

Method Source Code


//package com.java2s;
/*//from  ww  w . j  a v  a  2  s  .  c om
 * Copyright (C) 2011 - 2012  GeoSolutions S.A.S.
 * http://www.geo-solutions.it
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

import java.io.File;

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

public class Main {
    /**
     * Create a subDirectory having the actual date as name, within a specified
     * destination directory.
     * 
     * @param destDir
     *            the destination directory where to build the "today"
     *            directory.
     * @return the created directory.
     */
    public static File createTodayDirectory(File destDir) {
        final SimpleDateFormat sdf = new SimpleDateFormat("yyyy_MM_dd");
        final String newPath = (new StringBuffer(destDir.getAbsolutePath().trim()).append(File.separatorChar)
                .append(sdf.format(new Date()))).toString();
        File dir = new File(newPath);
        if (!dir.exists())
            dir.mkdir();
        return dir;
    }
}

Related

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