• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java YearMonth类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: call

import org.threeten.bp.YearMonth; //导入依赖的package包/类
@Override
@UiThread
public void call(final Subscriber<? super YearMonth> subscriber) {
  checkUiThread();

  calendarView.setOnMonthChangedListener(new OnMonthChangedListener() {
    @Override
    public void onMonthChanged(MaterialCalendarView widget, CalendarDay date) {
      if (!subscriber.isUnsubscribed()) {
        subscriber.onNext(DateHelper.calendarDayToYearMonth(date));
      }
    }
  });

  subscriber.add(new MainThreadSubscription() {
    @Override
    protected void onUnsubscribe() {
      calendarView.setOnMonthChangedListener(null);
    }
  });
}
 
开发者ID:xmartlabs,项目名称:XLMaterialCalendarView,代码行数:22,代码来源:CalendarViewMonthChangeOnSubscribe.java


示例2: propertySet

import org.threeten.bp.YearMonth; //导入依赖的package包/类
@Override
protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
  switch (propertyName.hashCode()) {
    case 537589661:  // futureType
      ((FutureSecurityDefinition) bean).setFutureType((ListedFutureType) newValue);
      return;
    case 106934601:  // price
      ((FutureSecurityDefinition) bean).setPrice((BigDecimal) newValue);
      return;
    case 797235414:  // futureExpiry
      ((FutureSecurityDefinition) bean).setFutureExpiry((YearMonth) newValue);
      return;
    case 389497452:  // settlementExchange
      ((FutureSecurityDefinition) bean).setSettlementExchange((String) newValue);
      return;
    case -295948169:  // settlementDate
      ((FutureSecurityDefinition) bean).setSettlementDate((LocalDate) newValue);
      return;
    case -673825823:  // futureCategory
      ((FutureSecurityDefinition) bean).setFutureCategory((String) newValue);
      return;
  }
  super.propertySet(bean, propertyName, newValue, quiet);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:25,代码来源:FutureSecurityDefinition.java


示例3: propertySet

import org.threeten.bp.YearMonth; //导入依赖的package包/类
@Override
protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
  switch (propertyName.hashCode()) {
    case -1985615124:  // listedOptionType
      ((OptionSecurityDefinition) bean).setListedOptionType((ListedOptionType) newValue);
      return;
    case 1373587791:  // optionType
      ((OptionSecurityDefinition) bean).setOptionType((OptionType) newValue);
      return;
    case -891985998:  // strike
      ((OptionSecurityDefinition) bean).setStrike((BigDecimal) newValue);
      return;
    case 1032553992:  // optionExpiry
      ((OptionSecurityDefinition) bean).setOptionExpiry((YearMonth) newValue);
      return;
    case -466331342:  // exerciseType
      ((OptionSecurityDefinition) bean).setExerciseType((ExerciseType) newValue);
      return;
  }
  super.propertySet(bean, propertyName, newValue, quiet);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:22,代码来源:OptionSecurityDefinition.java


示例4: ExpirationDate

import org.threeten.bp.YearMonth; //导入依赖的package包/类
/**
 * Expiration date parsed from raw track data.
 *
 * @param rawExpirationDate
 *        Raw track data for expiration date.
 */
public ExpirationDate(final String rawExpirationDate)
{
  super(rawExpirationDate);
  final String expirationDateString = non_digit
    .matcher(trimToEmpty(rawExpirationDate)).replaceAll("");
  YearMonth expirationDate;
  try
  {
    expirationDate = YearMonth.parse(expirationDateString, formatter);
  }
  catch (final Exception e)
  {
    expirationDate = null;
  }
  this.expirationDate = expirationDate;
}
 
开发者ID:sualeh,项目名称:credit_card_number,代码行数:23,代码来源:ExpirationDate.java


示例5: check

import org.threeten.bp.YearMonth; //导入依赖的package包/类
private void check(final YearMonth expectedExpirationDate,
                   final boolean isExpired)
{
  final String rawExpirationDate = formatter.format(expectedExpirationDate);
  final ExpirationDate expirationDate = new ExpirationDate(rawExpirationDate);
  assertEquals(rawExpirationDate, expirationDate.getRawData());
  assertTrue("Should have expiration date",
             expirationDate.hasExpirationDate());
  assertTrue(isExpired? expirationDate.isExpired()
                      : !expirationDate.isExpired());
  assertEquals(expectedExpirationDate, expirationDate.getExpirationDate());

  // System.out.println(String.format("%s - %s",
  // expectedExpirationDate,
  // expirationDate.getExpirationDateAsDate()));
}
 
开发者ID:sualeh,项目名称:credit_card_number,代码行数:17,代码来源:IsExpiredTest.java


示例6: doTest_comparisons_YearMonth

import org.threeten.bp.YearMonth; //导入依赖的package包/类
void doTest_comparisons_YearMonth(YearMonth... localDates) {
    for (int i = 0; i < localDates.length; i++) {
        YearMonth a = localDates[i];
        for (int j = 0; j < localDates.length; j++) {
            YearMonth b = localDates[j];
            if (i < j) {
                assertTrue(a.compareTo(b) < 0, a + " <=> " + b);
                assertEquals(a.isBefore(b), true, a + " <=> " + b);
                assertEquals(a.isAfter(b), false, a + " <=> " + b);
                assertEquals(a.equals(b), false, a + " <=> " + b);
            } else if (i > j) {
                assertTrue(a.compareTo(b) > 0, a + " <=> " + b);
                assertEquals(a.isBefore(b), false, a + " <=> " + b);
                assertEquals(a.isAfter(b), true, a + " <=> " + b);
                assertEquals(a.equals(b), false, a + " <=> " + b);
            } else {
                assertEquals(a.compareTo(b), 0, a + " <=> " + b);
                assertEquals(a.isBefore(b), false, a + " <=> " + b);
                assertEquals(a.isAfter(b), false, a + " <=> " + b);
                assertEquals(a.equals(b), true, a + " <=> " + b);
            }
        }
    }
}
 
开发者ID:ThreeTen,项目名称:threetenbp,代码行数:25,代码来源:TestYearMonth.java


示例7: monthChanges

import org.threeten.bp.YearMonth; //导入依赖的package包/类
/**
 * Create an observable which emits when the month changes in the {@code calendarView}.
 * <p>
 * <em>Warning:</em> The created observable keeps a strong reference to {@code view}. Unsubscribe
 * to free this reference.
 */
@CheckResult
@NonNull
public static Observable<YearMonth> monthChanges(@NonNull MaterialCalendarView calendarView) {
  checkNotNull(calendarView, "calendarView == null");
  return Observable.create(new CalendarViewMonthChangeOnSubscribe(calendarView));
}
 
开发者ID:xmartlabs,项目名称:XLMaterialCalendarView,代码行数:13,代码来源:RxCalendarView.java


示例8: calendarDayToYearMonth

import org.threeten.bp.YearMonth; //导入依赖的package包/类
@Test
public void calendarDayToYearMonth() {
  CalendarDay calendarDay = CalendarDay.from(2016, 10, 15);
  YearMonth expectedYearMonth = YearMonth.of(2016, 11);
  YearMonth actuaYearMonth = DateHelper.calendarDayToYearMonth(calendarDay);
  assertEquals(expectedYearMonth, actuaYearMonth);
}
 
开发者ID:xmartlabs,项目名称:XLMaterialCalendarView,代码行数:8,代码来源:DateHelperTest.java


示例9: propertySet

import org.threeten.bp.YearMonth; //导入依赖的package包/类
@Override
protected void propertySet(Bean bean, String propertyName, Object newValue, boolean quiet) {
  switch (propertyName.hashCode()) {
    case 1200280399:  // listedFutureOptionType
      ((FutureOptionSecurityDefinition) bean).setListedFutureOptionType((ListedFutureOptionType) newValue);
      return;
    case 1373587791:  // optionType
      ((FutureOptionSecurityDefinition) bean).setOptionType((OptionType) newValue);
      return;
    case -891985998:  // strike
      ((FutureOptionSecurityDefinition) bean).setStrike((BigDecimal) newValue);
      return;
    case 797235414:  // futureExpiry
      ((FutureOptionSecurityDefinition) bean).setFutureExpiry((YearMonth) newValue);
      return;
    case 1032553992:  // optionExpiry
      ((FutureOptionSecurityDefinition) bean).setOptionExpiry((YearMonth) newValue);
      return;
    case -466331342:  // exerciseType
      ((FutureOptionSecurityDefinition) bean).setExerciseType((ExerciseType) newValue);
      return;
    case -549878249:  // isMargined
      ((FutureOptionSecurityDefinition) bean).setIsMargined((Boolean) newValue);
      return;
  }
  super.propertySet(bean, propertyName, newValue, quiet);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:28,代码来源:FutureOptionSecurityDefinition.java


示例10: listOf

import org.threeten.bp.YearMonth; //导入依赖的package包/类
/**
 * Returns a list of IDs for futures with the specified expiries.
 *
 * @param expiries expiries of the other curve nodes
 * @return IDs for curve nodes for futures with the specified expiries
 */
public static List<FuturesExpiryCurveNodeId> listOf(YearMonth... expiries) {
  ImmutableList.Builder<FuturesExpiryCurveNodeId> builder = ImmutableList.builder();

  for (YearMonth otherExpiry : expiries) {
    builder.add(new FuturesExpiryCurveNodeId(otherExpiry));
  }
  return builder.build();
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:15,代码来源:FuturesExpiryCurveNodeId.java


示例11: set

import org.threeten.bp.YearMonth; //导入依赖的package包/类
@Override
public Builder set(String propertyName, Object newValue) {
  switch (propertyName.hashCode()) {
    case -1289159373:  // expiry
      this._expiry = (YearMonth) newValue;
      break;
    default:
      throw new NoSuchElementException("Unknown property: " + propertyName);
  }
  return this;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:12,代码来源:FuturesExpiryCurveNodeId.java


示例12: expirationDate1

import org.threeten.bp.YearMonth; //导入依赖的package包/类
@Test
public void expirationDate1()
{
  final String rawExpirationDate = "1212";
  final ExpirationDate expirationDate = new ExpirationDate(rawExpirationDate);
  assertEquals(rawExpirationDate, expirationDate.getRawData());
  assertEquals("2012-12", expirationDate.toString());
  assertTrue("Should have expiration date",
             expirationDate.hasExpirationDate());
  assertEquals(YearMonth.of(2012, 12), expirationDate.getExpirationDate());
}
 
开发者ID:sualeh,项目名称:credit_card_number,代码行数:12,代码来源:ExpirationDateTest.java


示例13: isExpired1

import org.threeten.bp.YearMonth; //导入依赖的package包/类
@Test
public void isExpired1()
{
  final YearMonth expirationDateNextMonth = YearMonth.now()
    .plus(1, ChronoUnit.MONTHS);
  check(expirationDateNextMonth, false);
}
 
开发者ID:sualeh,项目名称:credit_card_number,代码行数:8,代码来源:IsExpiredTest.java


示例14: isExpired3

import org.threeten.bp.YearMonth; //导入依赖的package包/类
@Test
public void isExpired3()
{
  final YearMonth expirationDateLastMonth = YearMonth.now()
    .minus(1, ChronoUnit.MONTHS);
  check(expirationDateLastMonth, true);
}
 
开发者ID:sualeh,项目名称:credit_card_number,代码行数:8,代码来源:IsExpiredTest.java


示例15: test_hashCode_unique

import org.threeten.bp.YearMonth; //导入依赖的package包/类
@Test
public void test_hashCode_unique() {
    int leapYear = 2008;
    Set<Integer> uniques = new HashSet<Integer>(366);
    for (int i = 1; i <= 12; i++) {
        for (int j = 1; j <= 31; j++) {
            if (YearMonth.of(leapYear, i).isValidDay(j)) {
                assertTrue(uniques.add(MonthDay.of(i, j).hashCode()));
            }
        }
    }
}
 
开发者ID:ThreeTen,项目名称:threetenbp,代码行数:13,代码来源:TestMonthDay.java


示例16: test_parseBest_String_parseError

import org.threeten.bp.YearMonth; //导入依赖的package包/类
@Test(expectedExceptions=DateTimeParseException.class)
public void test_parseBest_String_parseError() throws Exception {
    DateTimeFormatter test = DateTimeFormatter.ofPattern("uuuu-MM[-dd]");
    try {
        test.parseBest("2011-XX-30", LocalDate.FROM, YearMonth.FROM);
    } catch (DateTimeParseException ex) {
        assertEquals(ex.getMessage().contains("could not be parsed"), true);
        assertEquals(ex.getMessage().contains("XX"), true);
        assertEquals(ex.getParsedString(), "2011-XX-30");
        assertEquals(ex.getErrorIndex(), 5);
        throw ex;
    }
}
 
开发者ID:ThreeTen,项目名称:threetenbp,代码行数:14,代码来源:TestDateTimeFormatter.java


示例17: now

import org.threeten.bp.YearMonth; //导入依赖的package包/类
@Test
public void now() {
    YearMonth expected = YearMonth.now(Clock.systemDefaultZone());
    YearMonth test = YearMonth.now();
    for (int i = 0; i < 100; i++) {
        if (expected.equals(test)) {
            return;
        }
        expected = YearMonth.now(Clock.systemDefaultZone());
        test = YearMonth.now();
    }
    assertEquals(test, expected);
}
 
开发者ID:ThreeTen,项目名称:threetenbp,代码行数:14,代码来源:TestYearMonth.java


示例18: test_parseBest_String_parseErrorLongText

import org.threeten.bp.YearMonth; //导入依赖的package包/类
@Test(expectedExceptions=DateTimeParseException.class)
public void test_parseBest_String_parseErrorLongText() throws Exception {
    DateTimeFormatter test = fmt.withLocale(Locale.ENGLISH).withDecimalStyle(DecimalStyle.STANDARD);
    try {
        test.parseBest("ONEXXX67890123456789012345678901234567890123456789012345678901234567890123456789", LocalDate.FROM, YearMonth.FROM);
    } catch (DateTimeParseException ex) {
        assertEquals(ex.getMessage().contains("could not be parsed"), true);
        assertEquals(ex.getMessage().contains("ONEXXX6789012345678901234567890123456789012345678901234567890123..."), true);
        assertEquals(ex.getParsedString(), "ONEXXX67890123456789012345678901234567890123456789012345678901234567890123456789");
        assertEquals(ex.getErrorIndex(), 3);
        throw ex;
    }
}
 
开发者ID:ThreeTen,项目名称:threetenbp,代码行数:14,代码来源:TestDateTimeFormatter.java


示例19: now_Clock

import org.threeten.bp.YearMonth; //导入依赖的package包/类
@Test
public void now_Clock() {
    Instant instant = LocalDateTime.of(2010, 12, 31, 0, 0).toInstant(ZoneOffset.UTC);
    Clock clock = Clock.fixed(instant, ZoneOffset.UTC);
    YearMonth test = YearMonth.now(clock);
    assertEquals(test.getYear(), 2010);
    assertEquals(test.getMonth(), Month.DECEMBER);
}
 
开发者ID:ThreeTen,项目名称:threetenbp,代码行数:9,代码来源:TestYearMonth.java


示例20: factory_parse_fail

import org.threeten.bp.YearMonth; //导入依赖的package包/类
@Test(dataProvider="badParseData", expectedExceptions=DateTimeParseException.class)
public void factory_parse_fail(String text, int pos) {
    try {
        YearMonth.parse(text);
        fail(String.format("Parse should have failed for %s at position %d", text, pos));
    } catch (DateTimeParseException ex) {
        assertEquals(ex.getParsedString(), text);
        assertEquals(ex.getErrorIndex(), pos);
        throw ex;
    }
}
 
开发者ID:ThreeTen,项目名称:threetenbp,代码行数:12,代码来源:TestYearMonth.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DomainBareJid类代码示例发布时间:2022-05-23
下一篇:
Java IDiagramDocument类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap