本文整理汇总了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();
}