Here you can find the source of dayNumber(Timestamp stamp)
Parameter | Description |
---|---|
stamp | Timestamp date |
public static int dayNumber(Timestamp stamp)
//package com.java2s; //License from project: Apache License import java.sql.Timestamp; import java.util.Calendar; import java.util.Date; import java.util.Locale; import java.util.TimeZone; public class Main { /**//w ww . j a va 2 s . c om * returns a day number in a week for a Timestamp input * * @param stamp * Timestamp date * @return A int containing the day number (sunday = 1, saturday = 7) */ public static int dayNumber(Timestamp stamp) { Calendar tempCal = toCalendar(stamp, TimeZone.getDefault(), Locale.getDefault()); return tempCal.get(Calendar.DAY_OF_WEEK); } public static java.util.Calendar toCalendar(java.sql.Timestamp stamp) { Calendar cal = Calendar.getInstance(); if (stamp != null) { cal.setTimeInMillis(stamp.getTime()); } return cal; } /** * Returns a Calendar object initialized to the specified date/time, time * zone, and locale. * * @param date * date/time to use * @param timeZone * @param locale * @return Calendar object * @see java.util.Calendar */ public static Calendar toCalendar(Date date, TimeZone timeZone, Locale locale) { Calendar cal = Calendar.getInstance(timeZone, locale); if (date != null) { cal.setTime(date); } return cal; } }