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

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

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

YearMonth.getYear介绍

[英]Get the year field value.
[中]获取年份字段值。

代码示例

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

  1. /**
  2. * Converts this object to a LocalDate with the same year-month and chronology.
  3. *
  4. * @param dayOfMonth the day of month to use, valid for chronology, such as 1-31 for ISO
  5. * @return a LocalDate with the same year-month and chronology, never null
  6. */
  7. public LocalDate toLocalDate(int dayOfMonth) {
  8. return new LocalDate(getYear(), getMonthOfYear(), dayOfMonth, getChronology());
  9. }

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

  1. /**
  2. * Converts this object to a LocalDate with the same year-month and chronology.
  3. *
  4. * @param dayOfMonth the day of month to use, valid for chronology, such as 1-31 for ISO
  5. * @return a LocalDate with the same year-month and chronology, never null
  6. */
  7. public LocalDate toLocalDate(int dayOfMonth) {
  8. return new LocalDate(getYear(), getMonthOfYear(), dayOfMonth, getChronology());
  9. }

代码示例来源:origin: Graylog2/graylog2-server

  1. @Override
  2. @Nullable
  3. public Object convert(@Nullable String value) {
  4. if (isNullOrEmpty(value)) {
  5. return null;
  6. }
  7. LOG.debug("Trying to parse date <{}> with pattern <{}>, locale <{}>, and timezone <{}>.", value, dateFormat, locale, timeZone);
  8. final DateTimeFormatter formatter;
  9. if (containsTimeZone) {
  10. formatter = DateTimeFormat
  11. .forPattern(dateFormat)
  12. .withDefaultYear(YearMonth.now(timeZone).getYear())
  13. .withLocale(locale);
  14. } else {
  15. formatter = DateTimeFormat
  16. .forPattern(dateFormat)
  17. .withDefaultYear(YearMonth.now(timeZone).getYear())
  18. .withLocale(locale)
  19. .withZone(timeZone);
  20. }
  21. return DateTime.parse(value, formatter);
  22. }
  23. }

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

  1. /**
  2. * Converts this object to a LocalDate with the same year-month and chronology.
  3. *
  4. * @param dayOfMonth the day of month to use, valid for chronology, such as 1-31 for ISO
  5. * @return a LocalDate with the same year-month and chronology, never null
  6. */
  7. public LocalDate toLocalDate(int dayOfMonth) {
  8. return new LocalDate(getYear(), getMonthOfYear(), dayOfMonth, getChronology());
  9. }

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

  1. /**
  2. * Converts this object to a LocalDate with the same year-month and chronology.
  3. *
  4. * @param dayOfMonth the day of month to use, valid for chronology, such as 1-31 for ISO
  5. * @return a LocalDate with the same year-month and chronology, never null
  6. */
  7. public LocalDate toLocalDate(int dayOfMonth) {
  8. return new LocalDate(getYear(), getMonthOfYear(), dayOfMonth, getChronology());
  9. }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.joda-time

  1. /**
  2. * Converts this object to a LocalDate with the same year-month and chronology.
  3. *
  4. * @param dayOfMonth the day of month to use, valid for chronology, such as 1-31 for ISO
  5. * @return a LocalDate with the same year-month and chronology, never null
  6. */
  7. public LocalDate toLocalDate(int dayOfMonth) {
  8. return new LocalDate(getYear(), getMonthOfYear(), dayOfMonth, getChronology());
  9. }

代码示例来源:origin: io.virtdata/virtdata-lib-realer

  1. /**
  2. * Converts this object to a LocalDate with the same year-month and chronology.
  3. *
  4. * @param dayOfMonth the day of month to use, valid for chronology, such as 1-31 for ISO
  5. * @return a LocalDate with the same year-month and chronology, never null
  6. */
  7. public LocalDate toLocalDate(int dayOfMonth) {
  8. return new LocalDate(getYear(), getMonthOfYear(), dayOfMonth, getChronology());
  9. }

代码示例来源:origin: Nextdoor/bender

  1. /**
  2. * Converts this object to a LocalDate with the same year-month and chronology.
  3. *
  4. * @param dayOfMonth the day of month to use, valid for chronology, such as 1-31 for ISO
  5. * @return a LocalDate with the same year-month and chronology, never null
  6. */
  7. public LocalDate toLocalDate(int dayOfMonth) {
  8. return new LocalDate(getYear(), getMonthOfYear(), dayOfMonth, getChronology());
  9. }

代码示例来源:origin: redfish64/TinyTravelTracker

  1. /**
  2. * Converts this object to a LocalDate with the same year-month and chronology.
  3. *
  4. * @param dayOfMonth the day of month to use, valid for chronology, such as 1-31 for ISO
  5. * @return a LocalDate with the same year-month and chronology, never null
  6. */
  7. public LocalDate toLocalDate(int dayOfMonth) {
  8. return new LocalDate(getYear(), getMonthOfYear(), dayOfMonth, getChronology());
  9. }

代码示例来源:origin: org.graylog2/graylog2-server

  1. @Override
  2. @Nullable
  3. public Object convert(@Nullable String value) {
  4. if (isNullOrEmpty(value)) {
  5. return null;
  6. }
  7. LOG.debug("Trying to parse date <{}> with pattern <{}> and timezone <{}>.", value, dateFormat, timeZone);
  8. final DateTimeFormatter formatter = DateTimeFormat
  9. .forPattern(dateFormat)
  10. .withLocale(locale)
  11. .withDefaultYear(YearMonth.now(timeZone).getYear())
  12. .withZone(timeZone);
  13. return DateTime.parse(value, formatter);
  14. }
  15. }

代码示例来源:origin: pl.edu.icm.synat/synat-console-core

  1. private int getIntervalColumnsCount(Date intervalFrom, Date intervalTo) {
  2. YearMonth yearMonthStart = new YearMonth(intervalFrom.getTime());
  3. YearMonth yearMonthEnd = new YearMonth(intervalTo.getTime());
  4. int yearsDifference = yearMonthEnd.getYear() - yearMonthStart.getYear();
  5. int monthsDifference = yearMonthEnd.getMonthOfYear() - yearMonthStart.getMonthOfYear();
  6. return 1 + yearsDifference * 12 + monthsDifference;
  7. }

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

  1. /**
  2. * Converts this object to a LocalDate with the same year-month and chronology.
  3. *
  4. * @param dayOfMonth the day of month to use, valid for chronology, such as 1-31 for ISO
  5. * @return a LocalDate with the same year-month and chronology, never null
  6. */
  7. public LocalDate toLocalDate(int dayOfMonth) {
  8. return new LocalDate(getYear(), getMonthOfYear(), dayOfMonth, getChronology());
  9. }

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

  1. /**
  2. * Converts this object to a LocalDate with the same year-month and chronology.
  3. *
  4. * @param dayOfMonth the day of month to use, valid for chronology, such as 1-31 for ISO
  5. * @return a LocalDate with the same year-month and chronology, never null
  6. */
  7. public LocalDate toLocalDate(int dayOfMonth) {
  8. return new LocalDate(getYear(), getMonthOfYear(), dayOfMonth, getChronology());
  9. }

代码示例来源:origin: astamuse/asta4d

  1. @Test(dataProvider = "string2ym")
  2. public void testString2Java8YearMonth(String s, YearMonth ym) throws Exception {
  3. String2Java8YearMonth convertor = new String2Java8YearMonth();
  4. Assert.assertEquals(convertor.convert(s), java.time.YearMonth.of(ym.getYear(), ym.getMonthOfYear()));
  5. }
  6. }

代码示例来源:origin: pl.edu.icm.synat/synat-business-services-impl

  1. private PersistableMonthItem getMonthItem(PersistablePublicationDownload download, PersistableAbstractReportItem<?> item) {
  2. YearMonth yearMonth = new YearMonth(download.getDownloadDate());
  3. for (PersistableMonthItem monthItem : item.getMonthCounts()) {
  4. YearMonth itemYearMonth = new YearMonth(monthItem.getYear(), monthItem.getMonth());
  5. if (itemYearMonth.equals(yearMonth)) {
  6. return monthItem;
  7. }
  8. }
  9. PersistableMonthItem monthItem = new PersistableMonthItem();
  10. monthItem.setReportItem(item);
  11. monthItem.setMonth(yearMonth.getMonthOfYear());
  12. monthItem.setYear(yearMonth.getYear());
  13. item.getMonthCounts().add(monthItem);
  14. return monthItem;
  15. }

相关文章