當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。