本文整理了Java中java.util.Date.getDay()
方法的一些代码示例,展示了Date.getDay()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Date.getDay()
方法的具体详情如下:
包路径:java.util.Date
类名称:Date
方法名:getDay
[英]Returns the gregorian calendar day of the week for this Date object.
[中]返回此日期对象一周中的公历日。
代码示例来源:origin: spotbugs/spotbugs
public boolean isSaturday(Date d) {
return d.getDay() == 7;
}
代码示例来源:origin: BaronZ88/MinimalistWeather
/**
* 日期转换
*
* @return 08.07
*/
public static String convertDataToString(String dateString) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATA_FORMAT_PATTEN_YYYY_MM_DD, Locale.CHINA);
Date date = null;
try {
date = simpleDateFormat.parse(dateString);
} catch (ParseException e) {
e.printStackTrace();
}
if (date == null)
return "";
return (String.valueOf(date.getMonth()).length() == 1 ? "0" + date.getMonth() : String.valueOf(date.getMonth()))
+ "." + (String.valueOf(date.getDay()).length() == 1 ? "0" + date.getDay() : String.valueOf(date.getDay()));
}
代码示例来源:origin: TommyLemon/APIJSON
/**根据生日获取年龄
* @param birthday
* @return
*/
public static int getAge(Date birthday) {
if (birthday == null) {
return 0;
}
if (birthday.getYear() > getDateDetail(System.currentTimeMillis())[0]) {
birthday.setYear(birthday.getYear() - TimeUtil.SYSTEM_START_DATE[0]);
}
return getAge(new int[]{birthday.getYear(), birthday.getMonth(), birthday.getDay()});
}
/**根据生日获取年龄
代码示例来源:origin: TommyLemon/Android-ZBLibrary
/**根据生日获取年龄
* @param birthday
* @return
*/
public static int getAge(Date birthday) {
if (birthday == null) {
return 0;
}
if (birthday.getYear() > getDateDetail(System.currentTimeMillis())[0]) {
birthday.setYear(birthday.getYear() - TimeUtil.SYSTEM_START_DATE[0]);
}
return getAge(new int[]{birthday.getYear(), birthday.getMonth(), birthday.getDay()});
}
/**根据生日获取年龄
代码示例来源:origin: com.alibaba/fastjson
@SuppressWarnings("deprecation")
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
if (object == null) {
serializer.out.writeNull();
return;
}
Date date = (Date) object;
JSONObject json = new JSONObject();
json.put("date", date.getDate());
json.put("day", date.getDay());
json.put("hours", date.getHours());
json.put("minutes", date.getMinutes());
json.put("month", date.getMonth());
json.put("seconds", date.getSeconds());
json.put("time", date.getTime());
json.put("timezoneOffset", date.getTimezoneOffset());
json.put("year", date.getYear());
serializer.write(json);
}
}
代码示例来源:origin: stackoverflow.com
int miladiMonth = MiladiDate.getMonth() + 1;
int miladiDate = MiladiDate.getDate();
int WeekDay = MiladiDate.getDay();
代码示例来源:origin: stackoverflow.com
Date today = new Date();
Date myDate = new Date(today.getYear(),today.getMonth()-1,today.getDay());
System.out.println("My Date is"+myDate);
System.out.println("Today Date is"+today);
if (today.compareTo(myDate)<0)
System.out.println("Today Date is Lesser than my Date");
else if (today.compareTo(myDate)>0)
System.out.println("Today Date is Greater than my date");
else
System.out.println("Both Dates are equal");
代码示例来源:origin: com.google.gwt/gwt-servlet
/**
* Gets the first day of the first week in the currently specified month.
*
* @return the first day
*/
public Date getCurrentFirstDayOfFirstWeek() {
int wkDayOfMonth1st = currentMonth.getDay();
int start = CalendarUtil.getStartingDayOfWeek();
if (wkDayOfMonth1st == start) {
// always return a copy to allow SimpleCalendarView to adjust first
// display date
return new Date(currentMonth.getTime());
} else {
Date d = new Date(currentMonth.getTime());
int offset = wkDayOfMonth1st - start > 0 ? wkDayOfMonth1st - start
: DAYS_IN_WEEK - (start - wkDayOfMonth1st);
CalendarUtil.addDaysToDate(d, -offset);
return d;
}
}
代码示例来源:origin: com.google.gwt/gwt-servlet
/**
* Formats Day of week field according to pattern specified.
*
* @param buf where formatted string will be appended to
* @param count number of time pattern char repeats; this controls how a field
* should be formatted
* @param date hold the date object to be formatted
*/
private void formatDayOfWeek(StringBuilder buf, int count, Date date) {
@SuppressWarnings("deprecation")
int value = date.getDay();
if (count == 5) {
buf.append(dateTimeFormatInfo.weekdaysNarrow()[value]);
} else if (count == 4) {
buf.append(dateTimeFormatInfo.weekdaysFull()[value]);
} else {
buf.append(dateTimeFormatInfo.weekdaysShort()[value]);
}
}
代码示例来源:origin: com.google.gwt/gwt-servlet
/**
* Formats Standalone weekday field according to pattern specified.
*
* @param buf where formatted string will be appended to
* @param count number of time pattern char repeats; this controls how a field
* should be formatted
* @param date hold the date object to be formatted
*/
private void formatStandaloneDay(StringBuilder buf, int count, Date date) {
@SuppressWarnings("deprecation")
int value = date.getDay();
if (count == 5) {
buf.append(dateTimeFormatInfo.weekdaysNarrowStandalone()[value]);
} else if (count == 4) {
buf.append(dateTimeFormatInfo.weekdaysFullStandalone()[value]);
} else if (count == 3) {
buf.append(dateTimeFormatInfo.weekdaysShortStandalone()[value]);
} else {
zeroPaddingNumber(buf, value, 1);
}
}
代码示例来源:origin: com.google.gwt/gwt-servlet
if (this.dayOfMonth == -1) {
int adjustment = (7 + this.dayOfWeek - date.getDay()) % 7;
if (adjustment > 3) {
adjustment -= 7;
if (date.getDay() != this.dayOfWeek) {
return false;
代码示例来源:origin: com.google.gwt/gwt-servlet
/**
* Constructor.
*/
public CalendarModel() {
currentMonth = new Date();
CalendarUtil.setToFirstDayOfMonth(currentMonth);
// Finding day of week names
Date date = new Date();
for (int i = 1; i <= DAYS_IN_WEEK; i++) {
date.setDate(i);
int dayOfWeek = date.getDay();
dayOfWeekNames[dayOfWeek] = getDayOfWeekFormatter().format(date);
}
// Finding day of month names
date.setMonth(0);
for (int i = 1; i < MAX_DAYS_IN_MONTH; ++i) {
date.setDate(i);
dayOfMonthNames[i] = getDayOfMonthFormatter().format(date);
}
// finding month names
date.setDate(1);
for (int i = 0; i < MONTHS_IN_YEAR; ++i) {
date.setMonth(i);
monthOfYearNames[i] = getMonthFormatter().format(date);
}
}
代码示例来源:origin: com.extjs/gxt
/**
* Returns the day of the week
*
* @return the day of the week
*/
public int getDay() {
return date.getDay();
}
代码示例来源:origin: com.extjs/gxt
/**
* Returns the day of the week
*
* @return the day of the week
*/
public int getDayInWeek() {
return date.getDay();
}
代码示例来源:origin: openmrs/openmrs-core
@Test
public void retirePatientIdentifierType_shouldRetireAndSetReasonAndRetiredByAndDate() {
PatientService ps = Context.getPatientService();
PatientIdentifierType pit = ps.getPatientIdentifierType(1);
String reason = "moved away";
PatientIdentifierType result = ps.retirePatientIdentifierType(pit, reason);
assertTrue(result.getRetired());
assertEquals(result.getRetireReason(), reason);
assertEquals(result.getRetiredBy(), Context.getAuthenticatedUser());
Date today = new Date();
Date dateRetired = result.getDateRetired();
assertEquals(dateRetired.getDay(), today.getDay());
assertEquals(dateRetired.getMonth(), today.getMonth());
assertEquals(dateRetired.getYear(), today.getYear());
}
代码示例来源:origin: stackoverflow.com
Date date1; //Your initial date
Date date2; //Your initial second date
//Remove hours, minutes, seconds and milliseconds by creating new "clean" Date objects
Date compare1 = new Date(date1.getYear(), date1.getMonth(), date1.getDay());
Date compare2 = new Date(date2.getYear(), date2.getMonth(), date2.getDay());
if(compare1.compareTo(compare2) == 0){
}
代码示例来源:origin: de.mhus.lib/mhu-lib-core
@SuppressWarnings("deprecation")
@Override
public boolean isWorkingDay(Locale locale, Date date) {
return date.getDay() != 0 && !isHoliday(locale, date);
}
代码示例来源:origin: stackoverflow.com
Date todayDate = new Date();
todayDate.getDay();
todayDate.getHours();
todayDate.getMinutes();
todayDate.getMonth();
todayDate.getTime();
代码示例来源:origin: lindzh/hasting
@SuppressWarnings("deprecation")
public static long getMinute(Date date){
GregorianCalendar calendar = new GregorianCalendar(1900+date.getYear(),date.getMonth(),date.getDay(),date.getHours(),date.getMinutes());
return calendar.getTimeInMillis();
}
代码示例来源:origin: EvoSuite/evosuite
@SuppressWarnings("deprecation")
public int getDay() {
Capturer.capture(Instrumenter.CAPTURE_ID_JAVA_UTIL_DATE, this, "getDays", "()I", new Object[] {});
int ret = super.getDay();
Capturer.enable(Instrumenter.CAPTURE_ID_JAVA_UTIL_DATE, this, ret);
return ret;
}
内容来源于网络,如有侵权,请联系作者删除!