当前位置: 首页>>代码示例>>Java>>正文


Java DateTime.minusDays方法代码示例

本文整理汇总了Java中org.joda.time.DateTime.minusDays方法的典型用法代码示例。如果您正苦于以下问题:Java DateTime.minusDays方法的具体用法?Java DateTime.minusDays怎么用?Java DateTime.minusDays使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.joda.time.DateTime的用法示例。


在下文中一共展示了DateTime.minusDays方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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();
}
 
开发者ID:alamby,项目名称:upgradeToy,代码行数:11,代码来源:DateUtils.java

示例2: 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();

}
 
开发者ID:alamby,项目名称:upgradeToy,代码行数:15,代码来源:DateUtils.java

示例3: 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();

}
 
开发者ID:alamby,项目名称:upgradeToy,代码行数:15,代码来源:DateUtils.java

示例4: 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();

}
 
开发者ID:alamby,项目名称:upgradeToy,代码行数:15,代码来源:DateUtils.java

示例5: 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);
	return firstDate.toDate();
}
 
开发者ID:alamby,项目名称:upgradeToy,代码行数:13,代码来源:TimeUtils.java

示例6: getStartSinceDay

import org.joda.time.DateTime; //导入方法依赖的package包/类
private static final DateTime getStartSinceDay(int days) {
  DateTime utcNow = new DateTime(DateTimeZone.UTC);
  DateTime
      today =
      new DateTime(utcNow.getYear(), utcNow.getMonthOfYear(), utcNow.getDayOfMonth(), 0, 0, 0,
          DateTimeZone.UTC);
  return today.minusDays(days);
}
 
开发者ID:pinterest,项目名称:soundwave,代码行数:9,代码来源:EsInstanceStore.java

示例7: execute

import org.joda.time.DateTime; //导入方法依赖的package包/类
@Override
public void execute(MessageReceivedEvent event, String[] args) {
    DateTime current = new DateTime(DateTimeZone.forID("America/Montreal"));
    while (current.getDayOfWeek() != DateTimeConstants.TUESDAY) {
        current = current.minusDays(1);
    }
    int weeks = Weeks.weeksBetween(Utils.startDateMythicPlus, current).getWeeks();
    String[] weekAffixes = Utils.mythicPlusAffixes[weeks % 12];

    event.getChannel().sendMessage(Utils.createMythicEmbed(bot, event.getGuild(), weekAffixes).build()).queue();
}
 
开发者ID:greatman,项目名称:legendarybot,代码行数:12,代码来源:AffixCommand.java

示例8: addWeekView

import org.joda.time.DateTime; //导入方法依赖的package包/类
private void addWeekView() {
    View calendar = LayoutInflater.from(getContext()).inflate(R.layout.layout_calendar_content, this, false);
    calendar.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, calendarHeight));
    viewPagerContent = (ViewPager) calendar.findViewById(R.id.viewpager_calendar);
    addView(calendar);
    DateTime startDay = new DateTime(DateTimeZone.UTC);
    startDay = startDay.minusDays(startDay.getDayOfWeek() % DAYS_OF_WEEK);
    calendarPagerAdapter = new CalendarPagerAdapter(getContext(), maxCount, startDay, getViewHelper);
    viewPagerContent.setAdapter(calendarPagerAdapter);
    viewPagerContent.setCurrentItem(centerPosition);
}
 
开发者ID:LineChen,项目名称:Week_Calendar,代码行数:12,代码来源:WeekCalendar.java

示例9: gotoDate

import org.joda.time.DateTime; //导入方法依赖的package包/类
/**
 * 跳转到指定日期
 * @param dateTime 指定日期
 */
public void gotoDate(DateTime dateTime){
    viewPagerContent.setCurrentItem(centerPosition, true);
    DateTime startDay = dateTime.minusDays(dateTime.getDayOfWeek() % DAYS_OF_WEEK);
    calendarPagerAdapter.setStartDateTime(startDay);
    onWeekChange(centerPosition);
}
 
开发者ID:LineChen,项目名称:Week_Calendar,代码行数:11,代码来源:WeekCalendar.java

示例10: testDateWithoutOrigin

import org.joda.time.DateTime; //导入方法依赖的package包/类
public void testDateWithoutOrigin() throws Exception {
    DateTime dt = new DateTime(DateTimeZone.UTC);

    assertAcked(prepareCreate("test").addMapping(
            "type1",
            jsonBuilder().startObject().startObject("type1").startObject("properties").startObject("test").field("type", "text")
                    .endObject().startObject("num1").field("type", "date").endObject().endObject().endObject().endObject()));

    DateTime docDate = dt.minusDays(1);
    String docDateString = docDate.getYear() + "-" + String.format(Locale.ROOT, "%02d", docDate.getMonthOfYear()) + "-"
            + String.format(Locale.ROOT, "%02d", docDate.getDayOfMonth());
    client().index(
            indexRequest("test").type("type1").id("1")
                    .source(jsonBuilder().startObject().field("test", "value").field("num1", docDateString).endObject())).actionGet();
    docDate = dt.minusDays(2);
    docDateString = docDate.getYear() + "-" + String.format(Locale.ROOT, "%02d", docDate.getMonthOfYear()) + "-"
            + String.format(Locale.ROOT, "%02d", docDate.getDayOfMonth());
    client().index(
            indexRequest("test").type("type1").id("2")
                    .source(jsonBuilder().startObject().field("test", "value").field("num1", docDateString).endObject())).actionGet();
    docDate = dt.minusDays(3);
    docDateString = docDate.getYear() + "-" + String.format(Locale.ROOT, "%02d", docDate.getMonthOfYear()) + "-"
            + String.format(Locale.ROOT, "%02d", docDate.getDayOfMonth());
    client().index(
            indexRequest("test").type("type1").id("3")
                    .source(jsonBuilder().startObject().field("test", "value").field("num1", docDateString).endObject())).actionGet();

    refresh();

    ActionFuture<SearchResponse> response = client().search(
            searchRequest().searchType(SearchType.QUERY_THEN_FETCH).source(
                    searchSource().query(
                            functionScoreQuery(QueryBuilders.matchAllQuery(), new FilterFunctionBuilder[]{
                                    new FilterFunctionBuilder(linearDecayFunction("num1", null, "7000d")),
                                    new FilterFunctionBuilder(gaussDecayFunction("num1", null, "1d")),
                                    new FilterFunctionBuilder(exponentialDecayFunction("num1", null, "7000d"))
                            }).scoreMode(FiltersFunctionScoreQuery.ScoreMode.MULTIPLY))));

    SearchResponse sr = response.actionGet();
    assertNoFailures(sr);
    SearchHits sh = sr.getHits();
    assertThat(sh.getHits().length, equalTo(3));
    double[] scores = new double[4];
    for (int i = 0; i < sh.getHits().length; i++) {
        scores[Integer.parseInt(sh.getAt(i).getId()) - 1] = sh.getAt(i).getScore();
    }
    assertThat(scores[1], lessThan(scores[0]));
    assertThat(scores[2], lessThan(scores[1]));

}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:51,代码来源:DecayFunctionScoreIT.java


注:本文中的org.joda.time.DateTime.minusDays方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。