Java Code Examples for org.joda.time.DateTimeConstants#SUNDAY
The following examples show how to use
org.joda.time.DateTimeConstants#SUNDAY .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Alarm.java From prayer-times-android with Apache License 2.0 | 6 votes |
private static int jodaWDToJavaWD(int wd) { switch (wd) { case DateTimeConstants.MONDAY: return Calendar.MONDAY; case DateTimeConstants.TUESDAY: return Calendar.TUESDAY; case DateTimeConstants.WEDNESDAY: return Calendar.WEDNESDAY; case DateTimeConstants.THURSDAY: return Calendar.THURSDAY; case DateTimeConstants.FRIDAY: return Calendar.FRIDAY; case DateTimeConstants.SATURDAY: return Calendar.SATURDAY; case DateTimeConstants.SUNDAY: return Calendar.SUNDAY; } return 0; }
Example 2
Source File: Alarm.java From prayer-times-android with Apache License 2.0 | 6 votes |
private static int jodaWDToJavaWD(int wd) { switch (wd) { case DateTimeConstants.MONDAY: return Calendar.MONDAY; case DateTimeConstants.TUESDAY: return Calendar.TUESDAY; case DateTimeConstants.WEDNESDAY: return Calendar.WEDNESDAY; case DateTimeConstants.THURSDAY: return Calendar.THURSDAY; case DateTimeConstants.FRIDAY: return Calendar.FRIDAY; case DateTimeConstants.SATURDAY: return Calendar.SATURDAY; case DateTimeConstants.SUNDAY: return Calendar.SUNDAY; } return 0; }
Example 3
Source File: TimeUtils.java From LQRWeChat with MIT License | 5 votes |
/** * 得到仿微信日期格式输出 * * @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)); } }
Example 4
Source File: DateTimeFunctions.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
/** * Returns a date a number of workdays away. Saturday and Sundays are not considered working days. */ @Function("WORKDAY") @FunctionParameters({ @FunctionParameter("dateObject"), @FunctionParameter("workdays")}) public Date WORKDAY(Object dateObject, Integer workdays){ Date convertedDate = convertDateObject(dateObject); if(convertedDate==null){ logCannotConvertToDate(); return null; } else{ boolean lookBack = workdays<0; DateTime cursorDT=new DateTime(convertedDate); int remainingDays=Math.abs(workdays); while(remainingDays>0){ int dayOfWeek = cursorDT.getDayOfWeek(); if(!(dayOfWeek==DateTimeConstants.SATURDAY || dayOfWeek==DateTimeConstants.SUNDAY)){ // Decrement remaining days only when it is not Saturday or Sunday remainingDays--; } if(!lookBack) { cursorDT= dayOfWeek==DateTimeConstants.FRIDAY?cursorDT.plusDays(3):cursorDT.plusDays(1); } else { cursorDT= dayOfWeek==DateTimeConstants.MONDAY?cursorDT.minusDays(3):cursorDT.minusDays(1); } } return cursorDT.toDate(); } }
Example 5
Source File: DateTimeFunctions.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
/** * Returns the number of working days between two dates (inclusive). Saturday and Sunday are not considered working days. */ @Function("NETWORKDAYS") @FunctionParameters({ @FunctionParameter("startDate"), @FunctionParameter("endDate")}) public Integer NETWORKDAYS(Object startDate, Object endDate){ Date startDateObj = convertDateObject(startDate); if(startDateObj==null) { logCannotConvertToDate(); return null; } Date endDateObj = convertDateObject(endDate); if(endDateObj==null){ logCannotConvertToDate(); return null; } else{ LocalDate cursorLocalDate=new LocalDate(startDateObj); LocalDate endLocalDate=new LocalDate(endDateObj); int workingDays=0; if(cursorLocalDate.isAfter(endLocalDate)){ // Swap data information LocalDate tmp=cursorLocalDate; cursorLocalDate=endLocalDate; endLocalDate=tmp; } while (Days.daysBetween(cursorLocalDate, endLocalDate).getDays()>0){ int dayOfWeek = cursorLocalDate.getDayOfWeek(); if(!(dayOfWeek==DateTimeConstants.SATURDAY || dayOfWeek==DateTimeConstants.SUNDAY)){ workingDays++; } cursorLocalDate=cursorLocalDate.plusDays(1); } return workingDays; } }
Example 6
Source File: DateHelper.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
public final static int convertCalendarDayOfWeekToJoda(final int calendarDayOfWeek) { if (calendarDayOfWeek == Calendar.SUNDAY) { return DateTimeConstants.SUNDAY; } return calendarDayOfWeek - 1; }
Example 7
Source File: TimeUtils.java From OmniList with GNU Affero General Public License v3.0 | 4 votes |
public static Date thisFriday() { DateTime dateTime = new DateTime(); int week = dateTime.getDayOfWeek(); int offset = week == DateTimeConstants.SUNDAY ? 5 : 5 - week; return dateTime.plusDays(offset).withTimeAtStartOfDay().toDate(); }
Example 8
Source File: TimeUtils.java From OmniList with GNU Affero General Public License v3.0 | 4 votes |
public static Date thisSunday() { DateTime dateTime = new DateTime(); int week = dateTime.getDayOfWeek(); int offset = week == DateTimeConstants.SUNDAY ? 0 : -week; return dateTime.plusDays(offset).withTimeAtStartOfDay().toDate(); }
Example 9
Source File: TimeUtils.java From OmniList with GNU Affero General Public License v3.0 | 4 votes |
public static Date nextMonday() { DateTime dateTime = new DateTime(); int week = dateTime.getDayOfWeek(); int offset = week == DateTimeConstants.SUNDAY ? 1 : 8 - week; return dateTime.plusDays(offset).withTimeAtStartOfDay().toDate(); }
Example 10
Source File: DayOfWeekFromSundayDateTimeField.java From dremio-oss with Apache License 2.0 | 4 votes |
/** * Get the maximum value that this field can have. * * @return the field's maximum value */ @Override public int getMaximumValue() { // returns 7 which corresponds to SATURDAY for this impl return DateTimeConstants.SUNDAY; }
Example 11
Source File: WeeklySundayExpiryDayValidator.java From dhis2-android-datacapture with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override protected int weekStarts() { return DateTimeConstants.SUNDAY; }
Example 12
Source File: Jodatime.java From maven-framework-project with MIT License | 4 votes |
private static void getTimeInfo(){ System.out.println("-------------获取当前时间-----------------"); String weekStr=""; DateTime dt = new DateTime(); //年 int year = dt.getYear(); //月 int month = dt.getMonthOfYear(); //日 int day = dt.getDayOfMonth(); //星期 int week = dt.getDayOfWeek(); //点 int hour = dt.getHourOfDay(); //分 int min = dt.getMinuteOfHour(); //秒 int sec = dt.getSecondOfMinute(); //毫秒 int msec = dt.getMillisOfSecond(); //星期 switch(week) { case DateTimeConstants.SUNDAY: weekStr = "星期日"; System.out.println(weekStr); break; case DateTimeConstants.MONDAY: weekStr = "星期一"; System.out.println(weekStr); break; case DateTimeConstants.TUESDAY: weekStr = "星期二"; System.out.println(weekStr); break; case DateTimeConstants.WEDNESDAY: weekStr = "星期三"; System.out.println(weekStr); break; case DateTimeConstants.THURSDAY: weekStr = "星期四"; System.out.println(weekStr); break; case DateTimeConstants.FRIDAY: weekStr = "星期五"; System.out.println(weekStr); break; case DateTimeConstants.SATURDAY: weekStr = "星期六"; System.out.println(weekStr); break; } System.out.println(year + "/" + month + "/" + day + " " + hour + ":" + min + ":" + sec + ":" + msec + " " + weekStr); }
Example 13
Source File: GJDayOfWeekDateTimeField.java From astor with GNU General Public License v2.0 | 2 votes |
/** * Get the maximum value that this field can have. * * @return the field's maximum value */ public int getMaximumValue() { return DateTimeConstants.SUNDAY; }
Example 14
Source File: GJDayOfWeekDateTimeField.java From astor with GNU General Public License v2.0 | 2 votes |
/** * Get the maximum value that this field can have. * * @return the field's maximum value */ public int getMaximumValue() { return DateTimeConstants.SUNDAY; }