Here you can find the source of dayOfMonthOf(Date date)
Parameter | Description |
---|---|
date | the date to extract the day of month from - must not be null. |
Parameter | Description |
---|---|
NullPointerException | if given Date is null |
public static int dayOfMonthOf(Date date)
//package com.java2s; /**//from w w w . jav a 2s.co m * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. * * Copyright 2012-2016 the original author or authors. */ import java.util.Calendar; import java.util.Date; public class Main { /** * Dates Extracts the day of month of the given Date. * * @param date the date to extract the day of month from - must not be null. * @return the day of month of the given Date * @throws NullPointerException if given Date is null */ public static int dayOfMonthOf(Date date) { return toCalendar(date).get(Calendar.DAY_OF_MONTH); } /** * Converts the given Date to Calendar, returns null if the given Date is null. * * @param date the date to convert to a Calendar. * @return the Calendar corresponding to the given Date or null if the given Date is null. */ public static Calendar toCalendar(Date date) { if (date == null) { return null; } Calendar calendar = Calendar.getInstance(); calendar.setTime(date); return calendar; } }