org.joda.time.YearMonthDay.getChronology()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(10.6k)|赞(0)|评价(0)|浏览(99)

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

YearMonthDay.getChronology介绍

暂无

代码示例

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

/**
 * Converts this object to a LocalDate with the same date and chronology.
 *
 * @return a LocalDate with the same date and chronology
 * @since 1.3
 */
public LocalDate toLocalDate() {
  return new LocalDate(getYear(), getMonthOfYear(), getDayOfMonth(), getChronology());
}

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

/**
 * Converts this object to a LocalDate with the same date and chronology.
 *
 * @return a LocalDate with the same date and chronology
 * @since 1.3
 */
public LocalDate toLocalDate() {
  return new LocalDate(getYear(), getMonthOfYear(), getDayOfMonth(), getChronology());
}

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

/**
 * Converts this partial to a full datetime using the specified time zone
 * setting the date fields from this instance and the time fields from
 * the current time.
 * <p>
 * This method uses the chronology from this instance plus the time zone
 * specified.
 *
 * @param zone  the zone to use, null means default
 * @return this date as a datetime with the time as the current time
 */
public DateTime toDateTimeAtCurrentTime(DateTimeZone zone) {
  Chronology chrono = getChronology().withZone(zone);
  long instantMillis = DateTimeUtils.currentTimeMillis();
  long resolved = chrono.set(this, instantMillis);
  return new DateTime(resolved, chrono);
}

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

/**
 * Converts this partial to a full datetime using the specified time zone
 * setting the date fields from this instance and the time fields from
 * the current time.
 * <p>
 * This method uses the chronology from this instance plus the time zone
 * specified.
 *
 * @param zone  the zone to use, null means default
 * @return this date as a datetime with the time as the current time
 */
public DateTime toDateTimeAtCurrentTime(DateTimeZone zone) {
  Chronology chrono = getChronology().withZone(zone);
  long instantMillis = DateTimeUtils.currentTimeMillis();
  long resolved = chrono.set(this, instantMillis);
  return new DateTime(resolved, chrono);
}

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

/**
 * Converts this YearMonthDay to a full datetime at midnight using the
 * specified time zone.
 * <p>
 * This method uses the chronology from this instance plus the time zone
 * specified.
 *
 * @param zone  the zone to use, null means default
 * @return this date as a datetime at midnight
 */
public DateTime toDateTimeAtMidnight(DateTimeZone zone) {
  Chronology chrono = getChronology().withZone(zone);
  return new DateTime(getYear(), getMonthOfYear(), getDayOfMonth(), 0, 0, 0, 0, chrono);
}

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

/**
 * Converts this YearMonthDay to a full datetime at midnight using the
 * specified time zone.
 * <p>
 * This method uses the chronology from this instance plus the time zone
 * specified.
 *
 * @param zone  the zone to use, null means default
 * @return this date as a datetime at midnight
 */
public DateTime toDateTimeAtMidnight(DateTimeZone zone) {
  Chronology chrono = getChronology().withZone(zone);
  return new DateTime(getYear(), getMonthOfYear(), getDayOfMonth(), 0, 0, 0, 0, chrono);
}

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

/**
 * Converts this object to a DateTime using a TimeOfDay to fill in the
 * missing fields.
 * This instance is immutable and unaffected by this method call.
 * <p>
 * The resulting chronology is determined by the chronology of this
 * YearMonthDay plus the time zone.
 * The chronology of the time is ignored - only the field values are used.
 *
 * @param time  the time of day to use, null means current time
 * @param zone  the zone to get the DateTime in, null means default
 * @return the DateTime instance
 */
public DateTime toDateTime(TimeOfDay time, DateTimeZone zone) {
  Chronology chrono = getChronology().withZone(zone);
  long instant = DateTimeUtils.currentTimeMillis();
  instant = chrono.set(this, instant);
  if (time != null) {
    instant = chrono.set(time, instant);
  }
  return new DateTime(instant, chrono);
}

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

/**
 * Converts this object to a DateTime using a TimeOfDay to fill in the
 * missing fields.
 * This instance is immutable and unaffected by this method call.
 * <p>
 * The resulting chronology is determined by the chronology of this
 * YearMonthDay plus the time zone.
 * The chronology of the time is ignored - only the field values are used.
 *
 * @param time  the time of day to use, null means current time
 * @param zone  the zone to get the DateTime in, null means default
 * @return the DateTime instance
 */
public DateTime toDateTime(TimeOfDay time, DateTimeZone zone) {
  Chronology chrono = getChronology().withZone(zone);
  long instant = DateTimeUtils.currentTimeMillis();
  instant = chrono.set(this, instant);
  if (time != null) {
    instant = chrono.set(time, instant);
  }
  return new DateTime(instant, chrono);
}

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

/**
 * Returns a copy of this date with the year field updated.
 * <p>
 * YearMonthDay is immutable, so there are no set methods.
 * Instead, this method returns a new instance with the value of
 * year changed.
 *
 * @param year  the year to set
 * @return a copy of this object with the field set
 * @throws IllegalArgumentException if the value is invalid
 * @since 1.3
 */
public YearMonthDay withYear(int year) {
  int[] newValues = getValues();
  newValues = getChronology().year().set(this, YEAR, newValues, year);
  return new YearMonthDay(this, newValues);
}

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

/**
 * Returns a copy of this date with the day of month field updated.
 * <p>
 * YearMonthDay is immutable, so there are no set methods.
 * Instead, this method returns a new instance with the value of
 * day of month changed.
 *
 * @param dayOfMonth  the day of month to set
 * @return a copy of this object with the field set
 * @throws IllegalArgumentException if the value is invalid
 * @since 1.3
 */
public YearMonthDay withDayOfMonth(int dayOfMonth) {
  int[] newValues = getValues();
  newValues = getChronology().dayOfMonth().set(this, DAY_OF_MONTH, newValues, dayOfMonth);
  return new YearMonthDay(this, newValues);
}

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

/**
 * Returns a copy of this date with the month of year field updated.
 * <p>
 * YearMonthDay is immutable, so there are no set methods.
 * Instead, this method returns a new instance with the value of
 * month of year changed.
 *
 * @param monthOfYear  the month of year to set
 * @return a copy of this object with the field set
 * @throws IllegalArgumentException if the value is invalid
 * @since 1.3
 */
public YearMonthDay withMonthOfYear(int monthOfYear) {
  int[] newValues = getValues();
  newValues = getChronology().monthOfYear().set(this, MONTH_OF_YEAR, newValues, monthOfYear);
  return new YearMonthDay(this, newValues);
}

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

/**
 * Converts this object to a DateMidnight.
 *
 * @param zone  the zone to get the DateMidnight in, null means default
 * @return the DateMidnight instance
 */
public DateMidnight toDateMidnight(DateTimeZone zone) {
  Chronology chrono = getChronology().withZone(zone);
  return new DateMidnight(getYear(), getMonthOfYear(), getDayOfMonth(), chrono);
}

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

/**
 * Converts this object to a DateMidnight.
 *
 * @param zone  the zone to get the DateMidnight in, null means default
 * @return the DateMidnight instance
 */
public DateMidnight toDateMidnight(DateTimeZone zone) {
  Chronology chrono = getChronology().withZone(zone);
  return new DateMidnight(getYear(), getMonthOfYear(), getDayOfMonth(), chrono);
}

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

/**
 * Returns a copy of this date with the year field updated.
 * <p>
 * YearMonthDay is immutable, so there are no set methods.
 * Instead, this method returns a new instance with the value of
 * year changed.
 *
 * @param year  the year to set
 * @return a copy of this object with the field set
 * @throws IllegalArgumentException if the value is invalid
 * @since 1.3
 */
public YearMonthDay withYear(int year) {
  int[] newValues = getValues();
  newValues = getChronology().year().set(this, YEAR, newValues, year);
  return new YearMonthDay(this, newValues);
}

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

/**
 * Returns a copy of this date with the month of year field updated.
 * <p>
 * YearMonthDay is immutable, so there are no set methods.
 * Instead, this method returns a new instance with the value of
 * month of year changed.
 *
 * @param monthOfYear  the month of year to set
 * @return a copy of this object with the field set
 * @throws IllegalArgumentException if the value is invalid
 * @since 1.3
 */
public YearMonthDay withMonthOfYear(int monthOfYear) {
  int[] newValues = getValues();
  newValues = getChronology().monthOfYear().set(this, MONTH_OF_YEAR, newValues, monthOfYear);
  return new YearMonthDay(this, newValues);
}

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

/**
 * Returns a copy of this date with the day of month field updated.
 * <p>
 * YearMonthDay is immutable, so there are no set methods.
 * Instead, this method returns a new instance with the value of
 * day of month changed.
 *
 * @param dayOfMonth  the day of month to set
 * @return a copy of this object with the field set
 * @throws IllegalArgumentException if the value is invalid
 * @since 1.3
 */
public YearMonthDay withDayOfMonth(int dayOfMonth) {
  int[] newValues = getValues();
  newValues = getChronology().dayOfMonth().set(this, DAY_OF_MONTH, newValues, dayOfMonth);
  return new YearMonthDay(this, newValues);
}

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

/**
 * Returns a copy of this date with the specified chronology.
 * This instance is immutable and unaffected by this method call.
 * <p>
 * This method retains the values of the fields, thus the result will
 * typically refer to a different instant.
 * <p>
 * The time zone of the specified chronology is ignored, as YearMonthDay
 * operates without a time zone.
 *
 * @param newChronology  the new chronology, null means ISO
 * @return a copy of this datetime with a different chronology
 * @throws IllegalArgumentException if the values are invalid for the new chronology
 */
public YearMonthDay withChronologyRetainFields(Chronology newChronology) {
  newChronology = DateTimeUtils.getChronology(newChronology);
  newChronology = newChronology.withUTC();
  if (newChronology == getChronology()) {
    return this;
  } else {
    YearMonthDay newYearMonthDay = new YearMonthDay(this, newChronology);
    newChronology.validate(newYearMonthDay, getValues());
    return newYearMonthDay;
  }
}

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

/**
 * Returns a copy of this date with the specified chronology.
 * This instance is immutable and unaffected by this method call.
 * <p>
 * This method retains the values of the fields, thus the result will
 * typically refer to a different instant.
 * <p>
 * The time zone of the specified chronology is ignored, as YearMonthDay
 * operates without a time zone.
 *
 * @param newChronology  the new chronology, null means ISO
 * @return a copy of this datetime with a different chronology
 * @throws IllegalArgumentException if the values are invalid for the new chronology
 */
public YearMonthDay withChronologyRetainFields(Chronology newChronology) {
  newChronology = DateTimeUtils.getChronology(newChronology);
  newChronology = newChronology.withUTC();
  if (newChronology == getChronology()) {
    return this;
  } else {
    YearMonthDay newYearMonthDay = new YearMonthDay(this, newChronology);
    newChronology.validate(newYearMonthDay, getValues());
    return newYearMonthDay;
  }
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Converts this object to a LocalDate with the same date and chronology.
 *
 * @return a LocalDate with the same date and chronology
 * @since 1.3
 */
public LocalDate toLocalDate() {
  return new LocalDate(getYear(), getMonthOfYear(), getDayOfMonth(), getChronology());
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Converts this object to a DateMidnight.
 *
 * @param zone  the zone to get the DateMidnight in, null means default
 * @return the DateMidnight instance
 */
public DateMidnight toDateMidnight(DateTimeZone zone) {
  Chronology chrono = getChronology().withZone(zone);
  return new DateMidnight(getYear(), getMonthOfYear(), getDayOfMonth(), chrono);
}

相关文章