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

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

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

Date.getDate介绍

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

代码示例

代码示例来源:origin: ZHENFENG13/My-Blog

public static boolean isToday(Date date) {
  Date now = new Date();
  boolean result = true;
  result &= date.getYear() == now.getYear();
  result &= date.getMonth() == now.getMonth();
  result &= date.getDate() == now.getDate();
  return result;
}

代码示例来源:origin: prestodb/presto

/**
 * Constructs a MonthDay from a <code>java.util.Date</code>
 * using exactly the same field values avoiding any time zone effects.
 * <p>
 * Each field is queried from the Date and assigned to the MonthDay.
 * <p>
 * This factory method always creates a MonthDay with ISO chronology.
 *
 * @param date  the Date to extract fields from
 * @return the created MonthDay, never null
 * @throws IllegalArgumentException if the calendar is null
 * @throws IllegalArgumentException if the monthOfYear or dayOfMonth is invalid for the ISO chronology
 */
@SuppressWarnings("deprecation")
public static MonthDay fromDateFields(Date date) {
  if (date == null) {
    throw new IllegalArgumentException("The date must not be null");
  }
  return new MonthDay(date.getMonth() + 1, date.getDate());
}

代码示例来源:origin: prestodb/presto

/**
 * Constructs a YearMonthDay from a <code>java.util.Date</code>
 * using exactly the same field values avoiding any time zone effects.
 * <p>
 * Each field is queried from the Date and assigned to the YearMonthDay.
 * This is useful if you have been using the Date as a local date,
 * ignoring the zone.
 * <p>
 * This factory method always creates a YearMonthDay with ISO chronology.
 *
 * @param date  the Date to extract fields from
 * @return the created YearMonthDay
 * @throws IllegalArgumentException if the calendar is null
 * @throws IllegalArgumentException if the date is invalid for the ISO chronology
 * @since 1.2
 */
public static YearMonthDay fromDateFields(Date date) {
  if (date == null) {
    throw new IllegalArgumentException("The date must not be null");
  }
  return new YearMonthDay(
    date.getYear() + 1900,
    date.getMonth() + 1,
    date.getDate()
  );
}

代码示例来源:origin: prestodb/presto

public Date toDate() {
  int dom = getDayOfMonth();
  Date date = new Date(getYear() - 1900, getMonthOfYear() - 1, dom);
  LocalDate check = LocalDate.fromDateFields(date);
  if (check.isBefore(this)) {
    while (date.getDate() == dom) {
      date.setTime(date.getTime() - 1000);
  } else if (check.equals(this)) {
    Date earlier = new Date(date.getTime() - TimeZone.getDefault().getDSTSavings());
    if (earlier.getDate() == dom) {
      date = earlier;

代码示例来源:origin: org.mobicents.smsc/domain

private boolean checkUnprocessed() {
  synchronized (this) {
    Date cur = new Date();
    int day = cur.getDate();
    int mon = cur.getMonth();
    if (this.dayProcessed != day || this.monthProcessed != mon) {
      this.dayProcessed = day;
      this.monthProcessed = mon;
      return true;
    } else {
      return false;
    }
  }
}

代码示例来源:origin: apache/hbase

/**
 * Checks if the mob file is expired.
 * @param column The descriptor of the current column family.
 * @param current The current time.
 * @param fileDate The date string parsed from the mob file name.
 * @return True if the mob file is expired.
 */
public static boolean isMobFileExpired(ColumnFamilyDescriptor column, long current, String fileDate) {
 if (column.getMinVersions() > 0) {
  return false;
 }
 long timeToLive = column.getTimeToLive();
 if (Integer.MAX_VALUE == timeToLive) {
  return false;
 }
 Date expireDate = new Date(current - timeToLive * 1000);
 expireDate = new Date(expireDate.getYear(), expireDate.getMonth(), expireDate.getDate());
 try {
  Date date = parseDate(fileDate);
  if (date.getTime() < expireDate.getTime()) {
   return true;
  }
 } catch (ParseException e) {
  LOG.warn("Failed to parse the date " + fileDate, e);
  return false;
 }
 return false;
}

代码示例来源:origin: joda-time/joda-time

public Date toDate() {
  int dom = getDayOfMonth();
  Date date = new Date(getYear() - 1900, getMonthOfYear() - 1, dom);
  LocalDate check = LocalDate.fromDateFields(date);
  if (check.isBefore(this)) {
    while (date.getDate() == dom) {
      date.setTime(date.getTime() - 1000);
  } else if (check.equals(this)) {
    Date earlier = new Date(date.getTime() - TimeZone.getDefault().getDSTSavings());
    if (earlier.getDate() == dom) {
      date = earlier;

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

Date    date    = Calendar.getInstance().getTime();
   Date date2= new Date(2000,06,16);
   if( !(date2.getMonth()+" "+date.getDate()).equals(date.getMonth()+1+" "+date.getDate()))
   return;

代码示例来源:origin: joda-time/joda-time

/**
 * Constructs a YearMonthDay from a <code>java.util.Date</code>
 * using exactly the same field values avoiding any time zone effects.
 * <p>
 * Each field is queried from the Date and assigned to the YearMonthDay.
 * This is useful if you have been using the Date as a local date,
 * ignoring the zone.
 * <p>
 * This factory method always creates a YearMonthDay with ISO chronology.
 *
 * @param date  the Date to extract fields from
 * @return the created YearMonthDay
 * @throws IllegalArgumentException if the calendar is null
 * @throws IllegalArgumentException if the date is invalid for the ISO chronology
 * @since 1.2
 */
public static YearMonthDay fromDateFields(Date date) {
  if (date == null) {
    throw new IllegalArgumentException("The date must not be null");
  }
  return new YearMonthDay(
    date.getYear() + 1900,
    date.getMonth() + 1,
    date.getDate()
  );
}

代码示例来源:origin: joda-time/joda-time

/**
 * Constructs a MonthDay from a <code>java.util.Date</code>
 * using exactly the same field values avoiding any time zone effects.
 * <p>
 * Each field is queried from the Date and assigned to the MonthDay.
 * <p>
 * This factory method always creates a MonthDay with ISO chronology.
 *
 * @param date  the Date to extract fields from
 * @return the created MonthDay, never null
 * @throws IllegalArgumentException if the calendar is null
 * @throws IllegalArgumentException if the monthOfYear or dayOfMonth is invalid for the ISO chronology
 */
@SuppressWarnings("deprecation")
public static MonthDay fromDateFields(Date date) {
  if (date == null) {
    throw new IllegalArgumentException("The date must not be null");
  }
  return new MonthDay(date.getMonth() + 1, date.getDate());
}

代码示例来源:origin: h2oai/h2o-3

/**
 * Instantiate an AutoML object and start it running.  Progress can be tracked via its job().
 *
 * @param buildSpec
 * @return
 */
public static AutoML startAutoML(AutoMLBuildSpec buildSpec) {
 Date startTime = new Date();  // this is the one and only startTime for this run
 synchronized (AutoML.class) {
  // protect against two runs whose startTime is the same second
  if (lastStartTime != null) {
   while (lastStartTime.getYear() == startTime.getYear() &&
       lastStartTime.getMonth() == startTime.getMonth() &&
       lastStartTime.getDate() == startTime.getDate() &&
       lastStartTime.getHours() == startTime.getHours() &&
       lastStartTime.getMinutes() == startTime.getMinutes() &&
       lastStartTime.getSeconds() == startTime.getSeconds())
    startTime = new Date();
  }
  lastStartTime = startTime;
 }
 String keyString = buildSpec.build_control.project_name;
 AutoML aml = AutoML.makeAutoML(Key.<AutoML>make(keyString), startTime, buildSpec);
 DKV.put(aml);
 startAutoML(aml);
 return aml;
}

代码示例来源:origin: JodaOrg/joda-time

public Date toDate() {
  int dom = getDayOfMonth();
  Date date = new Date(getYear() - 1900, getMonthOfYear() - 1, dom);
  LocalDate check = LocalDate.fromDateFields(date);
  if (check.isBefore(this)) {
    while (date.getDate() == dom) {
      date.setTime(date.getTime() - 1000);
  } else if (check.equals(this)) {
    Date earlier = new Date(date.getTime() - TimeZone.getDefault().getDSTSavings());
    if (earlier.getDate() == dom) {
      date = earlier;

代码示例来源:origin: protegeproject/webprotege

private static String getMinimalDayMonthYearRendering(long timestamp) {
  final Date timestampDate = new Date(timestamp);
  return formatDay(timestampDate.getDate()) + " " + formatMonth(timestampDate.getMonth()) + " " + formatYear(timestampDate);
}

代码示例来源:origin: JodaOrg/joda-time

/**
 * Constructs a YearMonthDay from a <code>java.util.Date</code>
 * using exactly the same field values avoiding any time zone effects.
 * <p>
 * Each field is queried from the Date and assigned to the YearMonthDay.
 * This is useful if you have been using the Date as a local date,
 * ignoring the zone.
 * <p>
 * This factory method always creates a YearMonthDay with ISO chronology.
 *
 * @param date  the Date to extract fields from
 * @return the created YearMonthDay
 * @throws IllegalArgumentException if the calendar is null
 * @throws IllegalArgumentException if the date is invalid for the ISO chronology
 * @since 1.2
 */
public static YearMonthDay fromDateFields(Date date) {
  if (date == null) {
    throw new IllegalArgumentException("The date must not be null");
  }
  return new YearMonthDay(
    date.getYear() + 1900,
    date.getMonth() + 1,
    date.getDate()
  );
}

代码示例来源:origin: JodaOrg/joda-time

/**
 * Constructs a MonthDay from a <code>java.util.Date</code>
 * using exactly the same field values avoiding any time zone effects.
 * <p>
 * Each field is queried from the Date and assigned to the MonthDay.
 * <p>
 * This factory method always creates a MonthDay with ISO chronology.
 *
 * @param date  the Date to extract fields from
 * @return the created MonthDay, never null
 * @throws IllegalArgumentException if the calendar is null
 * @throws IllegalArgumentException if the monthOfYear or dayOfMonth is invalid for the ISO chronology
 */
@SuppressWarnings("deprecation")
public static MonthDay fromDateFields(Date date) {
  if (date == null) {
    throw new IllegalArgumentException("The date must not be null");
  }
  return new MonthDay(date.getMonth() + 1, date.getDate());
}

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

Date MiladiDate = new Date();
calcSolarCalendar(MiladiDate);
int miladiYear = MiladiDate.getYear() + 1900;
int miladiMonth = MiladiDate.getMonth() + 1;
int miladiDate = MiladiDate.getDate();
int WeekDay = MiladiDate.getDay();

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

Uri.Builder builder = Uri.parse("content://com.android.calendar/instances/when").buildUpon();
long now = new Date().getTime();
      final Date begin = new Date(eventCursor.getLong(1));
      final Date end = new Date(eventCursor.getLong(2));
      final Boolean allDay = !eventCursor.getString(3).equals("0");
      System.out.println("only date begin of events="+begin.getDate());
      System.out.println("only begin time of events="+begin.getHours() + ":" +begin.getMinutes() + ":" +begin.getSeconds());
      System.out.println("only date begin of events="+end.getDate());
      System.out.println("only begin time of events="+end.getHours() + ":" +end.getMinutes() + ":" +end.getSeconds());
      beg_date = begin.getDate();
      mbeg_date = begin.getDate()+"/"+calendar_metting_beginmonth+"/"+calendar_metting_beginyear;
      beg_time = begin.getHours();
      end_date = end.getDate();
      end_time = end.getHours();

代码示例来源:origin: joda-time/joda-time

date.getYear() + 1900,
  date.getMonth() + 1,
  date.getDate()
);

代码示例来源:origin: SonarSource/sonarqube

@Test
public void test_get_date() {
 Settings settings = new MapSettings(definitions);
 assertThat(settings.getDate("unknown")).isNull();
 assertThat(settings.getDate("date").getDate()).isEqualTo(18);
 assertThat(settings.getDate("date").getMonth()).isEqualTo(4);
}

代码示例来源:origin: nice-swa/my-site

public static boolean isToday(Date date) {
  Date now = new Date();
  boolean result = true;
  result &= date.getYear() == now.getYear();
  result &= date.getMonth() == now.getMonth();
  result &= date.getDate() == now.getDate();
  return result;
}

相关文章