我正在使用date sql而getDay()
返回此日期所代表的星期几。返回值(0 = Sunday, 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday
)
//type of dateStart and dateEnd is java.sql.Date
//type of DateTime is joda.time.DateTime
public static Date[][] getListPeriod(Date dateStart , Date dateEnd){
DateTime start = new DateTime(dateStart.getYear()+1900,dateStart.getMonth()+1,dateStart.getDay(), 0, 0, 0, 0);
示例:dateStart的值:2015-07-01
并dateStart.getDay()
返回2015-07-03(3 =星期三)
我希望dateStart.getDay()
获得此值1
答案 0 :(得分:2)
如何使用new DateTime(dateStart.getTime())
?
要从java.sql.Date
获取当天(当月),您必须使用getDate
。此方法继承自java.util.Date
并已弃用。从日期获取零件的正确方法是使用Calendar
。