java.util.Date.setDate()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(194)

本文整理了Java中java.util.Date.setDate()方法的一些代码示例,展示了Date.setDate()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Date.setDate()方法的具体详情如下:
包路径:java.util.Date
类名称:Date
方法名:setDate

Date.setDate介绍

[英]Sets the gregorian calendar day of the month for this Date object.
[中]设置此日期对象当月的公历日。

代码示例

代码示例来源:origin: spotbugs/spotbugs

public void falsePositive() {
  Date today = Calendar.getInstance().getTime();
  System.out.println(today);
  today.setDate(16);
  System.out.println(today);
}

代码示例来源:origin: com.google.gwt/gwt-servlet

@Override
public void setDate(int date) {
 checkFrozen();
 super.setDate(date);
}

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Adds the given number of days to a date.
 * 
 * @param date the date
 * @param days number of days
 */
@SuppressWarnings("deprecation") // GWT requires Date
public static void addDaysToDate(Date date, int days) {
 date.setDate(date.getDate() + days);
}

代码示例来源:origin: com.google.gwt/gwt-servlet

/**
 * Sets a date object to be at the beginning of the month and no time
 * specified.
 * 
 * @param date the date
 */
@SuppressWarnings("deprecation") // GWT requires Date
public static void setToFirstDayOfMonth(Date date) {
 resetTime(date);
 date.setDate(1);
}

代码示例来源: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.google.gwt/gwt-servlet

date.setDate(1);
 date.setDate(this.dayOfMonth);
} else if (this.month >= 0) {
 date.setDate(Math.min(daysInCurrentMonth, orgDayOfMonth));
} else {
 date.setDate(orgDayOfMonth);
  date.setDate(date.getDate() + adjustment);
   date.setDate(date.getDate() + (adjustment > 0 ? -7 : 7));

代码示例来源:origin: mulesoft/mule

@Test
public void fromDate() {
 Date date = new Date();
 date.setYear(0);
 date.setMonth(0);
 date.setDate(1);
 assertEquals(1900, new DateTime(date).getYear());
 assertEquals(1, new DateTime(date).getMonth());
 assertEquals(1, new DateTime(date).getDayOfMonth());
}

代码示例来源:origin: mulesoft/mule

@Test
public void fromDate() {
 Date date = new Date();
 date.setYear(0);
 date.setMonth(0);
 date.setDate(1);
 assertEquals(1900, new DateTime(date).getYear());
 assertEquals(1, new DateTime(date).getMonth());
 assertEquals(1, new DateTime(date).getDayOfMonth());
}

代码示例来源:origin: mulesoft/mule

@Test
public void fromDate() {
 Date date = new Date();
 date.setYear(0);
 date.setMonth(0);
 date.setDate(1);
 assertEquals(1900, new DateTime(date).getYear());
 assertEquals(1, new DateTime(date).getMonth());
 assertEquals(1, new DateTime(date).getDayOfMonth());
}

代码示例来源:origin: stackoverflow.com

long now = System.currentTimeMillis();
 System.out.println(now); //'now' being the 14th of the month
 Date day = new Date();
 System.out.println(day);
 day.setDate(21); // one week later
 long day2 = day.getTime();
 System.out.println(day2); 
 long week = day2-now;
 System.out.println(week);

代码示例来源:origin: com.vaadin.external.gwt/gwt-user

/**
 * Adds the given number of days to a date.
 * 
 * @param date the date
 * @param days number of days
 */
@SuppressWarnings("deprecation") // GWT requires Date
public static void addDaysToDate(Date date, int days) {
 date.setDate(date.getDate() + days);
}

代码示例来源:origin: net.wetheinter/gwt-user

/**
 * Sets a date object to be at the beginning of the month and no time
 * specified.
 * 
 * @param date the date
 */
@SuppressWarnings("deprecation") // GWT requires Date
public static void setToFirstDayOfMonth(Date date) {
 resetTime(date);
 date.setDate(1);
}

代码示例来源:origin: com.vaadin.external.gwt/gwt-user

/**
 * Sets a date object to be at the beginning of the month and no time
 * specified.
 * 
 * @param date the date
 */
@SuppressWarnings("deprecation") // GWT requires Date
public static void setToFirstDayOfMonth(Date date) {
 resetTime(date);
 date.setDate(1);
}

代码示例来源:origin: com.google.web.bindery/requestfactory-server

@Override
public void setDate(int date) {
 checkFrozen();
 super.setDate(date);
}

代码示例来源:origin: com.vaadin.external.gwt/gwt-user

@Override
public void setDate(int date) {
 checkFrozen();
 super.setDate(date);
}

代码示例来源:origin: stackoverflow.com

public static String getMonthName(int month){
  Locale locale = Locale.getDefault();
  SimpleDateFormat sdf = new SimpleDateFormat("MMMM",locale);
  Date date = new Date();
  date.setDate(1);
  date.setMonth(month);
  date.setYear(2012);
  return sdf.format(date);
}

代码示例来源:origin: stackoverflow.com

Date date = new Date();
date.setYear(2010);
date.setMonth(07);
date.setDate(14)
date.setHours(9);
date.setMinutes(0);
date.setSeconds(0);
String time = new SimpleDateFormat("HH:mm:ss").format(date);

代码示例来源:origin: org.kie.soup/kie-soup-dataset-api

@Before
public void setUp() throws Exception {
  Date startTime = new Date();
  startTime.setYear(115);
  startTime.setMonth(10);
  startTime.setDate(10);
  startTime.setHours(12);
  startTime.setMinutes(50);
  startTime.setSeconds(30);
  TimeInstant.START_TIME = startTime;
}

代码示例来源:origin: org.dashbuilder/dashbuilder-dataset-api

@Before
public void setUp() throws Exception {
  Date startTime = new Date();
  startTime.setYear(115);
  startTime.setMonth(10);
  startTime.setDate(10);
  startTime.setHours(12);
  startTime.setMinutes(50);
  startTime.setSeconds(30);
  TimeInstant.START_TIME = startTime;
}

代码示例来源:origin: org.mule.runtime/mule-core-tests

@Test
public void fromDate() {
 Date date = new Date();
 date.setYear(0);
 date.setMonth(0);
 date.setDate(1);
 assertEquals(1900, new DateTime(date).getYear());
 assertEquals(1, new DateTime(date).getMonth());
 assertEquals(1, new DateTime(date).getDayOfMonth());
}

相关文章