当前位置: 首页>>代码示例>>Java>>正文


Java LocalGregorianCalendar.Date方法代码示例

本文整理汇总了Java中sun.util.calendar.LocalGregorianCalendar.Date方法的典型用法代码示例。如果您正苦于以下问题:Java LocalGregorianCalendar.Date方法的具体用法?Java LocalGregorianCalendar.Date怎么用?Java LocalGregorianCalendar.Date使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sun.util.calendar.LocalGregorianCalendar的用法示例。


在下文中一共展示了LocalGregorianCalendar.Date方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTransitionEraIndex

import sun.util.calendar.LocalGregorianCalendar; //导入方法依赖的package包/类
/**
 * Returns the index to the new era if the given date is in a
 * transition month.  For example, if the give date is Heisei 1
 * (1989) January 20, then the era index for Heisei is
 * returned. Likewise, if the given date is Showa 64 (1989)
 * January 3, then the era index for Heisei is returned. If the
 * given date is not in any transition month, then -1 is returned.
 */
private static int getTransitionEraIndex(LocalGregorianCalendar.Date date) {
    int eraIndex = getEraIndex(date);
    CalendarDate transitionDate = eras[eraIndex].getSinceDate();
    if (transitionDate.getYear() == date.getNormalizedYear() &&
        transitionDate.getMonth() == date.getMonth()) {
        return eraIndex;
    }
    if (eraIndex < eras.length - 1) {
        transitionDate = eras[++eraIndex].getSinceDate();
        if (transitionDate.getYear() == date.getNormalizedYear() &&
            transitionDate.getMonth() == date.getMonth()) {
            return eraIndex;
        }
    }
    return -1;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:JapaneseImperialCalendar.java

示例2: getFixedDateMonth1

import sun.util.calendar.LocalGregorianCalendar; //导入方法依赖的package包/类
/**
 * Returns the fixed date of the first date of the month (usually
 * the 1st of the month) before the specified date.
 *
 * @param date the date for which the first day of the month is
 * calculated. The date must be in the era transition year.
 * @param fixedDate the fixed date representation of the date
 */
private long getFixedDateMonth1(LocalGregorianCalendar.Date date,
                                      long fixedDate) {
    int eraIndex = getTransitionEraIndex(date);
    if (eraIndex != -1) {
        long transition = sinceFixedDates[eraIndex];
        // If the given date is on or after the transition date, then
        // return the transition date.
        if (transition <= fixedDate) {
            return transition;
        }
    }

    // Otherwise, we can use the 1st day of the month.
    return fixedDate - date.getDayOfMonth() + 1;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:24,代码来源:JapaneseImperialCalendar.java

示例3: prolepticYear

import sun.util.calendar.LocalGregorianCalendar; //导入方法依赖的package包/类
@Override
public int prolepticYear(Era era, int yearOfEra) {
    if (era instanceof JapaneseEra == false) {
        throw new ClassCastException("Era must be JapaneseEra");
    }

    JapaneseEra jera = (JapaneseEra) era;
    int gregorianYear = jera.getPrivateEra().getSinceDate().getYear() + yearOfEra - 1;
    if (yearOfEra == 1) {
        return gregorianYear;
    }
    if (gregorianYear >= Year.MIN_VALUE && gregorianYear <= Year.MAX_VALUE) {
        LocalGregorianCalendar.Date jdate = JCAL.newCalendarDate(null);
        jdate.setEra(jera.getPrivateEra()).setDate(yearOfEra, 1, 1);
        if (JapaneseChronology.JCAL.validate(jdate)) {
            return gregorianYear;
        }
    }
    throw new DateTimeException("Invalid yearOfEra value");
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:21,代码来源:JapaneseChronology.java

示例4: getFixedDateMonth1

import sun.util.calendar.LocalGregorianCalendar; //导入方法依赖的package包/类
/**
    * Returns the fixed date of the first date of the month (usually
    * the 1st of the month) before the specified date.
    *
    * @param date the date for which the first day of the month is
    * calculated. The date must be in the era transition year.
    * @param fixedDate the fixed date representation of the date
    */
   private final long getFixedDateMonth1(LocalGregorianCalendar.Date date,
				  long fixedDate) {
int eraIndex = getTransitionEraIndex(date);
if (eraIndex != -1) {
    long transition = sinceFixedDates[eraIndex];
    // If the given date is on or after the transition date, then
    // return the transition date.
    if (transition <= fixedDate) {
	return transition;
    }
}

// Otherwise, we can use the 1st day of the month.
return fixedDate - date.getDayOfMonth() + 1;
   }
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:24,代码来源:JapaneseImperialCalendar.java

示例5: getTransitionEraIndex

import sun.util.calendar.LocalGregorianCalendar; //导入方法依赖的package包/类
/**
 * Returns the index to the new era if the given date is in a
 * transition month.  For example, if the give date is Heisei 1
 * (1989) January 20, then the era index for Heisei is
 * returned. Likewise, if the given date is Showa 64 (1989)
 * January 3, then the era index for Heisei is returned. If the
 * given date is not in any transition month, then -1 is returned.
 */
private static final int getTransitionEraIndex(LocalGregorianCalendar.Date date) {
    int eraIndex = getEraIndex(date);
    CalendarDate transitionDate = eras[eraIndex].getSinceDate();
    if (transitionDate.getYear() == date.getNormalizedYear() &&
        transitionDate.getMonth() == date.getMonth()) {
        return eraIndex;
    }
    if (eraIndex < eras.length - 1) {
        transitionDate = eras[++eraIndex].getSinceDate();
        if (transitionDate.getYear() == date.getNormalizedYear() &&
            transitionDate.getMonth() == date.getMonth()) {
            return eraIndex;
        }
    }
    return -1;
}
 
开发者ID:ZhaoX,项目名称:jdk-1.7-annotated,代码行数:25,代码来源:JapaneseImperialCalendar.java

示例6: getLong

import sun.util.calendar.LocalGregorianCalendar; //导入方法依赖的package包/类
@Override
public long getLong(DateTimeField field) {

  if (field instanceof ChronoField) {
    switch ((ChronoField) field) {
      case YEAR_OF_ERA:
        return this.yearOfEra;
      case ERA:
        return this.era.getValue();
      case DAY_OF_YEAR: {
        LocalGregorianCalendar.Date jdate = toPrivateJapaneseDate(this.isoDate);
        return JapaneseChrono.JCAL.getDayOfYear(jdate);
      }
    }
    // TODO: review other fields
    return this.isoDate.getLong(field);
  }
  return field.doGet(this);
}
 
开发者ID:m-m-m,项目名称:java8-backports,代码行数:20,代码来源:JapaneseDate.java

示例7: getFixedDateMonth1

import sun.util.calendar.LocalGregorianCalendar; //导入方法依赖的package包/类
/**
 * Returns the fixed date of the first date of the month (usually
 * the 1st of the month) before the specified date.
 *
 * @param date the date for which the first day of the month is
 * calculated. The date must be in the era transition year.
 * @param fixedDate the fixed date representation of the date
 */
private final long getFixedDateMonth1(LocalGregorianCalendar.Date date,
                                      long fixedDate) {
    int eraIndex = getTransitionEraIndex(date);
    if (eraIndex != -1) {
        long transition = sinceFixedDates[eraIndex];
        // If the given date is on or after the transition date, then
        // return the transition date.
        if (transition <= fixedDate) {
            return transition;
        }
    }

    // Otherwise, we can use the 1st day of the month.
    return fixedDate - date.getDayOfMonth() + 1;
}
 
开发者ID:greghaskins,项目名称:openjdk-jdk7u-jdk,代码行数:24,代码来源:JapaneseImperialCalendar.java

示例8: prolepticYear

import sun.util.calendar.LocalGregorianCalendar; //导入方法依赖的package包/类
@Override
public int prolepticYear(Era<JapaneseChrono> era, int yearOfEra) {

  if (era instanceof JapaneseEra == false) {
    throw new DateTimeException("Era must be JapaneseEra");
  }
  JapaneseEra jera = (JapaneseEra) era;
  int gregorianYear = jera.getPrivateEra().getSinceDate().getYear() + yearOfEra - 1;
  if (yearOfEra == 1) {
    return gregorianYear;
  }
  LocalGregorianCalendar.Date jdate = JCAL.newCalendarDate(null);
  jdate.setEra(jera.getPrivateEra()).setDate(yearOfEra, 1, 1);
  JCAL.normalize(jdate);
  if (jdate.getNormalizedYear() == gregorianYear) {
    return gregorianYear;
  }
  throw new DateTimeException("invalid yearOfEra value");
}
 
开发者ID:m-m-m,项目名称:java8-backports,代码行数:20,代码来源:JapaneseChrono.java

示例9: getEraIndex

import sun.util.calendar.LocalGregorianCalendar; //导入方法依赖的package包/类
private static int getEraIndex(LocalGregorianCalendar.Date date) {
    Era era = date.getEra();
    for (int i = eras.length - 1; i > 0; i--) {
        if (eras[i] == era) {
            return i;
        }
    }
    return 0;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:JapaneseImperialCalendar.java

示例10: JapaneseDate

import sun.util.calendar.LocalGregorianCalendar; //导入方法依赖的package包/类
/**
 * Creates an instance from an ISO date.
 *
 * @param isoDate  the standard local date, validated not null
 */
JapaneseDate(LocalDate isoDate) {
    if (isoDate.isBefore(MEIJI_6_ISODATE)) {
        throw new DateTimeException("JapaneseDate before Meiji 6 is not supported");
    }
    LocalGregorianCalendar.Date jdate = toPrivateJapaneseDate(isoDate);
    this.era = JapaneseEra.toJapaneseEra(jdate.getEra());
    this.yearOfEra = jdate.getYear();
    this.isoDate = isoDate;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:JapaneseDate.java

示例11: toPrivateJapaneseDate

import sun.util.calendar.LocalGregorianCalendar; //导入方法依赖的package包/类
/**
 * Returns a {@code LocalGregorianCalendar.Date} converted from the given {@code isoDate}.
 *
 * @param isoDate  the local date, not null
 * @return a {@code LocalGregorianCalendar.Date}, not null
 */
private static LocalGregorianCalendar.Date toPrivateJapaneseDate(LocalDate isoDate) {
    LocalGregorianCalendar.Date jdate = JapaneseChronology.JCAL.newCalendarDate(null);
    sun.util.calendar.Era sunEra = JapaneseEra.privateEraFrom(isoDate);
    int year = isoDate.getYear();
    if (sunEra != null) {
        year -= sunEra.getSinceDate().getYear() - 1;
    }
    jdate.setEra(sunEra).setYear(year).setMonth(isoDate.getMonthValue()).setDayOfMonth(isoDate.getDayOfMonth());
    JapaneseChronology.JCAL.normalize(jdate);
    return jdate;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:JapaneseDate.java

示例12: clone

import sun.util.calendar.LocalGregorianCalendar; //导入方法依赖的package包/类
public Object clone() {
    JapaneseImperialCalendar other = (JapaneseImperialCalendar) super.clone();

    other.jdate = (LocalGregorianCalendar.Date) jdate.clone();
    other.originalFields = null;
    other.zoneOffsets = null;
    return other;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:JapaneseImperialCalendar.java

示例13: readObject

import sun.util.calendar.LocalGregorianCalendar; //导入方法依赖的package包/类
/**
 * Reconstitutes this object from a stream.
 * 
 * @param stream object input stream
 */
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {

  stream.defaultReadObject();
  LocalGregorianCalendar.Date jdate = toPrivateJapaneseDate(this.isoDate);
  this.era = JapaneseEra.toJapaneseEra(jdate.getEra());
  this.yearOfEra = jdate.getYear();
}
 
开发者ID:m-m-m,项目名称:java8-backports,代码行数:13,代码来源:JapaneseDate.java

示例14: getEraIndex

import sun.util.calendar.LocalGregorianCalendar; //导入方法依赖的package包/类
private static final int getEraIndex(LocalGregorianCalendar.Date date) {
    Era era = date.getEra();
    for (int i = eras.length - 1; i > 0; i--) {
        if (eras[i] == era) {
            return i;
        }
    }
    return 0;
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:10,代码来源:JapaneseImperialCalendar.java

示例15: JapaneseDate

import sun.util.calendar.LocalGregorianCalendar; //导入方法依赖的package包/类
/**
 * Creates an instance from an ISO date.
 * 
 * @param isoDate the standard local date, validated not null
 */
JapaneseDate(LocalDate isoDate) {

  LocalGregorianCalendar.Date jdate = toPrivateJapaneseDate(isoDate);
  this.era = JapaneseEra.toJapaneseEra(jdate.getEra());
  this.yearOfEra = jdate.getYear();
  this.isoDate = isoDate;
}
 
开发者ID:m-m-m,项目名称:java8-backports,代码行数:13,代码来源:JapaneseDate.java


注:本文中的sun.util.calendar.LocalGregorianCalendar.Date方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。