Util.java Source code

Java tutorial

Introduction

Here is the source code for Util.java

Source

import java.io.File;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Calendar;
import java.util.Date;

public class Util {
    public static String getFilesystemPathFromDate(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        NumberFormat format = new DecimalFormat("00");
        return File.separator + format.format(calendar.get(Calendar.YEAR)) + File.separator
                + format.format((calendar.get(Calendar.MONTH) + 1)) + File.separator
                + format.format(calendar.get(Calendar.DAY_OF_MONTH)) + File.separator;
    }

}