org.geotools.feature.type.DateUtil.formatYearNumber()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(2.1k)|赞(0)|评价(0)|浏览(183)

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

DateUtil.formatYearNumber介绍

[英]Format year number consistent with W3C XML Schema definitions, using a minimum of four digits padded with zeros if necessary. A leading minus sign is included for years prior to 1 C.E.
[中]设置与W3CXML模式定义一致的年份号格式,必要时至少使用四位数字加上零。在1 C.E.之前的年份中包含一个前导减号。

代码示例

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

/**
 * Format time in milliseconds to year number. The resulting year number format is consistent
 * with W3C XML Schema definitions, using a minimum of four digits padded with zeros if
 * necessary. A leading minus sign is included for years prior to 1 C.E.
 *
 * @param value time in milliseconds to be converted (from 1 C.E.)
 * @param buff text formatting buffer
 */
protected static void formatYear(long value, StringBuffer buff) {
  // find the actual year and month number; this uses a integer arithmetic
  //  conversion based on Baum, first making the millisecond count
  //  relative to March 1 of the year 0 C.E., then using simple arithmetic
  //  operations to compute century, year, and month; it's slightly
  //  different for pre-C.E. values because of Java's handling of divisions.
  long time = value + (306 * LMSPERDAY) + ((LMSPERDAY * 3) / 4);
  long century = time / MSPERCENTURY; // count of centuries
  long adjusted = time + ((century - (century / 4)) * MSPERDAY);
  int year = (int) (adjusted / MSPERAVGYEAR); // year in March 1 terms
  if (adjusted < 0) {
    year--;
  }
  long yms = (adjusted + (LMSPERDAY / 4)) - (((year * 365) + (year / 4)) * LMSPERDAY);
  int yday = (int) (yms / LMSPERDAY); // day number in year
  int month = ((5 * yday) + 456) / 153; // (biased) month number
  if (month > 12) { // convert start of year
    year++;
  }
  // format year to text
  formatYearNumber(year, buff);
}

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

formatYearNumber(year, buff);
buff.append('-');
formatTwoDigits(month, buff);

代码示例来源:origin: org.geotools/gt-main

formatYearNumber(year, buff);

代码示例来源:origin: org.geotools/gt2-main

formatYearNumber(year, buff);

代码示例来源:origin: org.geotools/gt2-main

formatYearNumber(year, buff);
buff.append('-');
formatTwoDigits(month, buff);

代码示例来源:origin: org.geotools/gt-main

formatYearNumber(year, buff);
buff.append('-');
formatTwoDigits(month, buff);

相关文章