Here you can find the source of getDayOfMonthBy(Timestamp ts)
public static int getDayOfMonthBy(Timestamp ts)
//package com.java2s; //License from project: Open Source License import java.sql.Timestamp; import java.util.Calendar; public class Main { public static int getDayOfMonthBy(Timestamp ts) { Calendar calendar = getCalendar(); if (ts != null) calendar.setTimeInMillis(ts.getTime()); return calendar.get(Calendar.DAY_OF_MONTH); }/*from w w w . j a v a 2 s . c o m*/ public static int getDayOfMonthBy(java.sql.Date date) { Calendar calendar = getCalendar(); if (date != null) calendar.setTimeInMillis(date.getTime()); return calendar.get(Calendar.DAY_OF_MONTH); } public static int getDayOfMonthBy(long time) { Calendar calendar = getCalendar(); calendar.setTimeInMillis(time); return calendar.get(Calendar.DAY_OF_MONTH); } public static Calendar getCalendar() { return getCalendar(null); } public static Calendar getCalendar(Integer year) { return getCalendar(year, null, null); } public static Calendar getCalendar(Integer year, Integer month) { return getCalendar(year, month, null); } public static Calendar getCalendar(Integer year, Integer month, Integer date) { Calendar calendar = Calendar.getInstance(); if (year != null) calendar.set(Calendar.YEAR, year); if (month != null) calendar.set(Calendar.MONTH, month - 1); if (date != null) calendar.set(Calendar.DAY_OF_MONTH, date); return calendar; } }