當前位置: 首頁>>代碼示例>>Java>>正文


Java DateTime.getDayOfWeek方法代碼示例

本文整理匯總了Java中org.joda.time.DateTime.getDayOfWeek方法的典型用法代碼示例。如果您正苦於以下問題:Java DateTime.getDayOfWeek方法的具體用法?Java DateTime.getDayOfWeek怎麽用?Java DateTime.getDayOfWeek使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.joda.time.DateTime的用法示例。


在下文中一共展示了DateTime.getDayOfWeek方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: DayAdapter

import org.joda.time.DateTime; //導入方法依賴的package包/類
public DayAdapter(int calendarHeight, DateTime startDateTime, GetViewHelper getViewHelper, DateTime selectDateTime) {
    this.calendarHeight = calendarHeight;
    this.getViewHelper = getViewHelper;
    this.selectDateTime = selectDateTime;
    dateTimes = new ArrayList<>();

    final int daysOfMonth = startDateTime.dayOfMonth().getMaximumValue();
    int firstDayOfWeek = startDateTime.getDayOfWeek() % DAYS_OF_WEEK;

    for (int i = firstDayOfWeek; i >= 1; i--) {
        dateTimes.add(new Day(new DateTime(startDateTime).minusDays(i), true));
    }

    for (int i = 0; i < daysOfMonth; i++) {
        dateTimes.add(new Day(new DateTime(startDateTime).plusDays(i), false));
    }

    DateTime lastDay = dateTimes.get(dateTimes.size() - 1).getDateTime();
    int yy = DAYS_OF_WEEK - lastDay.getDayOfWeek() % DAYS_OF_WEEK;
    for (int i = 1; i < yy; i++) {
        dateTimes.add(new Day(new DateTime(lastDay).plusDays(i), true));
    }
}
 
開發者ID:LineChen,項目名稱:Month_Calendar,代碼行數:24,代碼來源:DayAdapter.java

示例2: getDateOfCurrentMonday

import org.joda.time.DateTime; //導入方法依賴的package包/類
private String getDateOfCurrentMonday() {
    DateTime currentDate = new DateTime();

    if (currentDate.getDayOfWeek() == DateTimeConstants.SATURDAY) {
        currentDate = currentDate.plusDays(2);
    } else if (currentDate.getDayOfWeek() == DateTimeConstants.SUNDAY) {
        currentDate = currentDate.plusDays(1);
    } else {
        currentDate = currentDate.withDayOfWeek(DateTimeConstants.MONDAY);
    }
    return currentDate.toString(DATE_PATTERN);
}
 
開發者ID:wulkanowy,項目名稱:wulkanowy,代碼行數:13,代碼來源:TimetableFragment.java

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

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

示例5: getLastDayOfWeek

import org.joda.time.DateTime; //導入方法依賴的package包/類
/**
 * 獲取某一天所在周的周日
 * 
 * @param date
 * @return
 */
public static Date getLastDayOfWeek(Date date) {
	DateTime dateTime = new DateTime(date.getTime());
	int dayOfWeek = dateTime.getDayOfWeek();

	DateTime theDateTime = new DateTime(date.getTime());
	theDateTime = theDateTime.plusDays(7 - dayOfWeek);
	return theDateTime.toDate();
}
 
開發者ID:alamby,項目名稱:upgradeToy,代碼行數:15,代碼來源:TimeUtils.java

示例6: getExpanded

import org.joda.time.DateTime; //導入方法依賴的package包/類
private boolean getExpanded(String dayDate) {
    DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern(DATE_PATTERN);
    DateTime dayTime = dateTimeFormatter.parseDateTime(dayDate);

    DateTime currentDate = new DateTime();

    if (currentDate.getDayOfWeek() == DateTimeConstants.SATURDAY) {
        currentDate = currentDate.plusDays(2);
    } else if (currentDate.getDayOfWeek() == DateTimeConstants.SUNDAY) {
        currentDate = currentDate.plusDays(1);
    }

    return DateTimeComparator.getDateOnlyInstance().compare(currentDate, dayTime) == 0;
}
 
開發者ID:wulkanowy,項目名稱:wulkanowy,代碼行數:15,代碼來源:TimetableFragmentTab.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: execute

import org.joda.time.DateTime; //導入方法依賴的package包/類
@Override
public void execute(MessageReceivedEvent event, String[] args) {
    DateTime current = new DateTime(DateTimeZone.forID("America/Montreal"));
    if (current.getDayOfWeek() == DateTimeConstants.TUESDAY) {
        current = current.plusDays(1);
    }
    while (current.getDayOfWeek() != DateTimeConstants.TUESDAY) {
        current = current.plusDays(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,代碼行數:14,代碼來源:NextAffixCommand.java

示例9: getWeekday

import org.joda.time.DateTime; //導入方法依賴的package包/類
/**
 * 計算當前是星期幾
 * 返回 星期x
 */
public static String getWeekday(Date date)
{
	DateTime dt = new DateTime(date);
	String weekday = "";
	//星期  
	switch(dt.getDayOfWeek()) {  
	case DateTimeConstants.SUNDAY:  
		weekday = "星期日";  
	    break;  
	case DateTimeConstants.MONDAY:  
		weekday = "星期一";  
	    break;  
	case DateTimeConstants.TUESDAY:  
		weekday = "星期二";  
	    break;  
	case DateTimeConstants.WEDNESDAY:  
		weekday = "星期三";  
	    break;  
	case DateTimeConstants.THURSDAY:  
		weekday = "星期四";  
	    break;  
	case DateTimeConstants.FRIDAY:  
		weekday = "星期五";  
	    break;  
	case DateTimeConstants.SATURDAY:  
		weekday = "星期六";  
	    break;  
	}  
	return weekday;
}
 
開發者ID:marlonwang,項目名稱:raven,代碼行數:35,代碼來源:DateUtils.java

示例10: getWeekday2

import org.joda.time.DateTime; //導入方法依賴的package包/類
/** 返回 周x */
public static String getWeekday2(Date date)
{
  DateTime dt = new DateTime(date);
  String weekday = "";
  //星期  
  switch(dt.getDayOfWeek()) {  
  case DateTimeConstants.SUNDAY:  
    weekday = "周日";  
      break;  
  case DateTimeConstants.MONDAY:  
    weekday = "周一";  
      break;  
  case DateTimeConstants.TUESDAY:  
    weekday = "周二";  
      break;  
  case DateTimeConstants.WEDNESDAY:  
    weekday = "周三";  
      break;  
  case DateTimeConstants.THURSDAY:  
    weekday = "周四";  
      break;  
  case DateTimeConstants.FRIDAY:  
    weekday = "周五";  
      break;  
  case DateTimeConstants.SATURDAY:  
    weekday = "周六";  
      break;  
  }  
  return weekday;
}
 
開發者ID:marlonwang,項目名稱:raven,代碼行數:32,代碼來源:DateUtils.java

示例11: getEnWeekday

import org.joda.time.DateTime; //導入方法依賴的package包/類
/** 返回 SUN,MON,TUE*/
public static String getEnWeekday(Date date)
{
	DateTime dt = new DateTime(date);
	String weekday = "";
	//星期  
	switch(dt.getDayOfWeek()) {  
	case DateTimeConstants.SUNDAY:  
		weekday = "SUN";  
	    break;  
	case DateTimeConstants.MONDAY:  
		weekday = "MON";  
	    break;  
	case DateTimeConstants.TUESDAY:  
		weekday = "TUE";  
	    break;  
	case DateTimeConstants.WEDNESDAY:  
		weekday = "WED";  
	    break;  
	case DateTimeConstants.THURSDAY:  
		weekday = "THU";  
	    break;  
	case DateTimeConstants.FRIDAY:  
		weekday = "FRI";  
	    break;  
	case DateTimeConstants.SATURDAY:  
		weekday = "SAT";  
	    break;  
	}  
	return weekday;
}
 
開發者ID:marlonwang,項目名稱:raven,代碼行數:32,代碼來源:DateUtils.java

示例12: parseTime

import org.joda.time.DateTime; //導入方法依賴的package包/類
/**
 * 輸入時間 XXXX-XX-XX 的字符串, 放回中文指代的時間, 比如 "今天 02/09"
 */
public static String parseTime(String timeText){
    DateTime dateTime = new DateTime();
    String[] time = timeText.split("-");

    int currentMonth = dateTime.getMonthOfYear();
    int currentDay = dateTime.getDayOfMonth();
    int currentWeak = dateTime.getDayOfWeek();
    int currentYear = dateTime.getYear();

    int month = Integer.parseInt(time[1]);
    int day = Integer.parseInt(time[2]);
    int year = Integer.parseInt(time[0]);

    int offset = 0;  // 相差量

    if (year == currentYear){
        //如果是同一年:
        if (month == currentMonth){
            // 如果是同一個月
            offset = day - currentDay;

        }else{
            offset = day + parseMonth(currentMonth, currentYear) - currentDay;
        }

    }else{
        offset = 31 - currentDay + day;
    }



    String monthAndDay = time[1] + "/" + time[2];
    if (offset == 0) return "今天 " + monthAndDay;
    if (offset == 1) return  "明天 " + monthAndDay;
    return parseWeak(currentWeak + offset) + " " + monthAndDay;

}
 
開發者ID:lentitude,項目名稱:BS-Weather,代碼行數:41,代碼來源:Time.java

示例13: getMsgFormatTime

import org.joda.time.DateTime; //導入方法依賴的package包/類
/**
     * 得到仿微信日期格式輸出
     *
     * @param msgTimeMillis
     * @return
     */
    public static String getMsgFormatTime(long msgTimeMillis) {
        DateTime nowTime = new DateTime();
//        LogUtils.sf("nowTime = " + nowTime);
        DateTime msgTime = new DateTime(msgTimeMillis);
//        LogUtils.sf("msgTime = " + msgTime);
        int days = Math.abs(Days.daysBetween(msgTime, nowTime).getDays());
//        LogUtils.sf("days = " + days);
        if (days < 1) {
            //早上、下午、晚上 1:40
            return getTime(msgTime);
        } else if (days == 1) {
            //昨天
            return "昨天 " + getTime(msgTime);
        } else if (days <= 7) {
            //星期
            switch (msgTime.getDayOfWeek()) {
                case DateTimeConstants.SUNDAY:
                    return "周日 " + getTime(msgTime);
                case DateTimeConstants.MONDAY:
                    return "周一 " + getTime(msgTime);
                case DateTimeConstants.TUESDAY:
                    return "周二 " + getTime(msgTime);
                case DateTimeConstants.WEDNESDAY:
                    return "周三 " + getTime(msgTime);
                case DateTimeConstants.THURSDAY:
                    return "周四 " + getTime(msgTime);
                case DateTimeConstants.FRIDAY:
                    return "周五 " + getTime(msgTime);
                case DateTimeConstants.SATURDAY:
                    return "周六 " + getTime(msgTime);
            }
            return "";
        } else {
            //12月22日
            return msgTime.toString("MM月dd日 " + getTime(msgTime));
        }
    }
 
開發者ID:starryxp,項目名稱:LQRWeChat-master,代碼行數:44,代碼來源:TimeUtils.java

示例14: parseTime

import org.joda.time.DateTime; //導入方法依賴的package包/類
/**
 * 解析API傳回的時間 XXXX-XX-XX 的字符串, 轉換為中文指代的時間, 比如 "今天 02/09"
 */
public static String parseTime(String timeText){
    DateTime dateTime = new DateTime();
    String[] time = timeText.split("-");

    int currentMonth = dateTime.getMonthOfYear();
    int currentDay = dateTime.getDayOfMonth();
    int currentWeak = dateTime.getDayOfWeek();
    int currentYear = dateTime.getYear();

    int month = Integer.parseInt(time[1]);
    int day = Integer.parseInt(time[2]);
    int year = Integer.parseInt(time[0]);

    int offset = 0;  // 相差量

    if (year == currentYear){
        //如果是同一年:
        if (month == currentMonth){
            // 如果是同一個月
            offset = day - currentDay;

        }else{
            offset = day + parseMonth(currentMonth, currentYear) - currentDay;
        }

    }else{
        offset = 31 - currentDay + day;
    }



    String monthAndDay = time[1] + "/" + time[2];
    if (offset == 0) return "今天 " + monthAndDay;
    if (offset == 1) return  "明天 " + monthAndDay;
    return parseWeak(currentWeak + offset) + " " + monthAndDay;

}
 
開發者ID:LynnYuki,項目名稱:CoolCloud-Weather,代碼行數:41,代碼來源:Time.java

示例15: isWeekend

import org.joda.time.DateTime; //導入方法依賴的package包/類
@Override
public boolean isWeekend(DateTime day) {
	return day.getDayOfWeek() == DateTimeConstants.SATURDAY || day.getDayOfWeek() == DateTimeConstants.SUNDAY;
}
 
開發者ID:adessoAG,項目名稱:JenkinsHue,代碼行數:5,代碼來源:HoldayServiceImpl.java


注:本文中的org.joda.time.DateTime.getDayOfWeek方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。