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


Java LocalGregorianCalendar类代码示例

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


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

示例1: 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:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:JapaneseChronology.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:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:JapaneseImperialCalendar.java

示例3: 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

示例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:jgaltidor,项目名称:VarJ,代码行数:25,代码来源:JapaneseImperialCalendar.java

示例6: 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:ZhaoX,项目名称:jdk-1.7-annotated,代码行数:24,代码来源:JapaneseImperialCalendar.java

示例7: 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

示例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: 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


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