Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Calendar;
import java.util.Date;

public class Main {

    public static String getDayOfMonth(Date date, boolean withZeroFill) {
        Calendar calendar = getCalendar(date);
        String day = (calendar.get(Calendar.DAY_OF_MONTH)) + "";
        return (day.length() == 1 && withZeroFill) ? ("0" + day) : day;
    }

    public static Calendar getCalendar(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        return calendar;
    }
}