本文整理匯總了Java中org.joda.time.DateTime.withTime方法的典型用法代碼示例。如果您正苦於以下問題:Java DateTime.withTime方法的具體用法?Java DateTime.withTime怎麽用?Java DateTime.withTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.joda.time.DateTime
的用法示例。
在下文中一共展示了DateTime.withTime方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getFirstDayOfWeek
import org.joda.time.DateTime; //導入方法依賴的package包/類
/**
* 獲取某一天所在周的周一
*
* @param date
* @return
*/
public static Date getFirstDayOfWeek(Date date) {
DateTime dateTime = new DateTime(date.getTime());
int dayOfWeek = dateTime.getDayOfWeek();
DateTime firstDate = dateTime.minusDays(dayOfWeek - 1);
firstDate = firstDate.withTime(0, 0, 0, 0);
return firstDate.toDate();
}
示例2: getFirstDayOfMonth
import org.joda.time.DateTime; //導入方法依賴的package包/類
/**
* 獲取某一天所在月的第一天
*
* @param date
* @return
*/
public static Date getFirstDayOfMonth(Date date) {
DateTime dateTime = new DateTime(date.getTime());
int dayOfMonth = dateTime.getDayOfMonth();
DateTime firstDate = dateTime.minusDays(dayOfMonth - 1);
firstDate = firstDate.withTime(0, 0, 0, 0);
return firstDate.toDate();
}
示例3: getFirstDayOfYear
import org.joda.time.DateTime; //導入方法依賴的package包/類
/**
* 獲取某一天所在年的第一天
*
* @param date
* @return
*/
public static Date getFirstDayOfYear(Date date) {
DateTime dateTime = new DateTime(date.getTime());
int dayOfYear = dateTime.getDayOfYear();
DateTime firstDate = dateTime.minusDays(dayOfYear - 1);
firstDate = firstDate.withTime(0, 0, 0, 0);
return firstDate.toDate();
}
示例4: getLastOfDay
import org.joda.time.DateTime; //導入方法依賴的package包/類
/**
* 獲取某一天最後時間
*
* @param date
* @return
*/
public static Date getLastOfDay(Date date) {
DateTime dateTime = new DateTime(date.getTime());
dateTime = dateTime.withTime(23, 59, 59, 0);
return dateTime.toDate();
}
示例5: getLastDay
import org.joda.time.DateTime; //導入方法依賴的package包/類
/**
* 獲取當前日期的前一天Date
*/
public static Date getLastDay() {
Date current = new Date();
DateTime dateTime = new DateTime(current);
dateTime = dateTime.minusDays(1);
dateTime = dateTime.withTime(0, 0, 0, 0);
return dateTime.toDate();
}