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


Java IsoFields类代码示例

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


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

示例1: getPreviousPeriod

import java.time.temporal.IsoFields; //导入依赖的package包/类
private long getPreviousPeriod(Tick tick, int indexOfPreviousTick) {
	switch (timeLevel) {
           case DAY: // return previous day
               int prevCalendarDay =  tick.getEndTime().minusDays(1).getDayOfYear();
               // skip weekend and holidays:
               while (getTimeSeries().getTick(indexOfPreviousTick).getEndTime().getDayOfYear() != prevCalendarDay && indexOfPreviousTick > 0) {
                   prevCalendarDay--;
               }
               return prevCalendarDay;
           case WEEK: // return previous week
               return tick.getEndTime().minusWeeks(1).get(IsoFields.WEEK_OF_WEEK_BASED_YEAR);
           case MONTH: // return previous month
               return tick.getEndTime().minusMonths(1).getMonthValue();
           default: // return previous year
               return tick.getEndTime().minusYears(1).getYear();
	}
}
 
开发者ID:ta4j,项目名称:ta4j,代码行数:18,代码来源:PivotPointIndicator.java

示例2: test_parse_parseLenientQuarter_SMART

import java.time.temporal.IsoFields; //导入依赖的package包/类
@Test(dataProvider = "parseLenientQuarter")
public void test_parse_parseLenientQuarter_SMART(String str, LocalDate expected, boolean smart) {
    DateTimeFormatter f = new DateTimeFormatterBuilder()
            .appendValue(YEAR).appendLiteral(':')
            .appendValue(IsoFields.QUARTER_OF_YEAR).appendLiteral(':')
            .appendValue(IsoFields.DAY_OF_QUARTER)
            .toFormatter().withResolverStyle(ResolverStyle.SMART);
    if (smart) {
        LocalDate parsed = LocalDate.parse(str, f);
        assertEquals(parsed, expected);
    } else {
        try {
            LocalDate.parse(str, f);
            fail("Should have failed");
        } catch (DateTimeParseException ex) {
            // expected
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:TCKIsoFields.java

示例3: test_parse_parseLenientWeek_SMART

import java.time.temporal.IsoFields; //导入依赖的package包/类
@Test(dataProvider = "parseLenientWeek")
public void test_parse_parseLenientWeek_SMART(String str, LocalDate expected, boolean smart) {
    DateTimeFormatter f = new DateTimeFormatterBuilder()
            .appendValue(IsoFields.WEEK_BASED_YEAR).appendLiteral(':')
            .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR).appendLiteral(':')
            .appendValue(DAY_OF_WEEK)
            .toFormatter().withResolverStyle(ResolverStyle.SMART);
    if (smart) {
        LocalDate parsed = LocalDate.parse(str, f);
        assertEquals(parsed, expected);
    } else {
        try {
            LocalDate.parse(str, f);
            fail("Should have failed");
        } catch (DateTimeParseException ex) {
            // expected
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:TCKIsoFields.java

示例4: data_resolveTwoNoChange

import java.time.temporal.IsoFields; //导入依赖的package包/类
@DataProvider(name="resolveTwoNoChange")
Object[][] data_resolveTwoNoChange() {
    return new Object[][]{
            {YEAR, 2012, MONTH_OF_YEAR, 5},
            {YEAR, 2012, DAY_OF_MONTH, 5},
            {YEAR, 2012, DAY_OF_WEEK, 5},
            {YEAR, 2012, ALIGNED_WEEK_OF_YEAR, 5},
            {YEAR, 2012, ALIGNED_WEEK_OF_MONTH, 5},
            {YEAR, 2012, IsoFields.QUARTER_OF_YEAR, 3},
            {YEAR, 2012, MINUTE_OF_HOUR, 5},
            {YEAR, 2012, SECOND_OF_MINUTE, 5},
            {YEAR, 2012, NANO_OF_SECOND, 5},

            {MONTH_OF_YEAR, 5, DAY_OF_MONTH, 5},
            {MONTH_OF_YEAR, 5, DAY_OF_WEEK, 5},
            {MONTH_OF_YEAR, 5, ALIGNED_WEEK_OF_YEAR, 5},
            {MONTH_OF_YEAR, 5, ALIGNED_WEEK_OF_MONTH, 5},
            {MONTH_OF_YEAR, 3, IsoFields.QUARTER_OF_YEAR, 5},
            {MONTH_OF_YEAR, 5, MINUTE_OF_HOUR, 5},
            {MONTH_OF_YEAR, 5, SECOND_OF_MINUTE, 5},
            {MONTH_OF_YEAR, 5, NANO_OF_SECOND, 5},
    };
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:24,代码来源:TCKDateTimeParseResolver.java

示例5: getPeriod

import java.time.temporal.IsoFields; //导入依赖的package包/类
private long getPeriod(Tick tick) {
       switch (timeLevel) {
           case DAY: // return previous day
               return tick.getEndTime().getDayOfYear();
           case WEEK: // return previous week
               return tick.getEndTime().get(IsoFields.WEEK_OF_WEEK_BASED_YEAR);
           case MONTH: // return previous month
               return tick.getEndTime().getMonthValue();
           default: // return previous year
               return tick.getEndTime().getYear();
       }
}
 
开发者ID:ta4j,项目名称:ta4j,代码行数:13,代码来源:PivotPointIndicator.java

示例6: test_parse_quarters

import java.time.temporal.IsoFields; //导入依赖的package包/类
@Test(dataProvider = "quarter")
public void test_parse_quarters(LocalDate date, int doq, int qoy) {
    DateTimeFormatter f = new DateTimeFormatterBuilder()
            .appendValue(YEAR).appendLiteral('-')
            .appendValue(IsoFields.QUARTER_OF_YEAR).appendLiteral('-')
            .appendValue(IsoFields.DAY_OF_QUARTER)
            .toFormatter().withResolverStyle(ResolverStyle.STRICT);
    LocalDate parsed = LocalDate.parse(date.getYear() + "-" + qoy + "-" + doq, f);
    assertEquals(parsed, date);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:TCKIsoFields.java

示例7: test_parse_quarters_SMART

import java.time.temporal.IsoFields; //导入依赖的package包/类
@Test(dataProvider = "quarter")
public void test_parse_quarters_SMART(LocalDate date, int doq, int qoy) {
    DateTimeFormatter f = new DateTimeFormatterBuilder()
            .appendValue(YEAR).appendLiteral('-')
            .appendValue(IsoFields.QUARTER_OF_YEAR).appendLiteral('-')
            .appendValue(IsoFields.DAY_OF_QUARTER)
            .toFormatter().withResolverStyle(ResolverStyle.SMART);
    LocalDate parsed = LocalDate.parse(date.getYear() + "-" + qoy + "-" + doq, f);
    assertEquals(parsed, date);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:TCKIsoFields.java

示例8: test_parse_quarters_LENIENT

import java.time.temporal.IsoFields; //导入依赖的package包/类
@Test(dataProvider = "quarter")
public void test_parse_quarters_LENIENT(LocalDate date, int doq, int qoy) {
    DateTimeFormatter f = new DateTimeFormatterBuilder()
            .appendValue(YEAR).appendLiteral('-')
            .appendValue(IsoFields.QUARTER_OF_YEAR).appendLiteral('-')
            .appendValue(IsoFields.DAY_OF_QUARTER)
            .toFormatter().withResolverStyle(ResolverStyle.LENIENT);
    LocalDate parsed = LocalDate.parse(date.getYear() + "-" + qoy + "-" + doq, f);
    assertEquals(parsed, date);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:TCKIsoFields.java

示例9: test_parse_parseLenientQuarter_STRICT

import java.time.temporal.IsoFields; //导入依赖的package包/类
@Test(dataProvider = "parseLenientQuarter", expectedExceptions = DateTimeParseException.class)
public void test_parse_parseLenientQuarter_STRICT(String str, LocalDate expected, boolean smart) {
    DateTimeFormatter f = new DateTimeFormatterBuilder()
            .appendValue(YEAR).appendLiteral(':')
            .appendValue(IsoFields.QUARTER_OF_YEAR).appendLiteral(':')
            .appendValue(IsoFields.DAY_OF_QUARTER)
            .toFormatter().withResolverStyle(ResolverStyle.STRICT);
    LocalDate.parse(str, f);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:TCKIsoFields.java

示例10: test_parse_parseLenientQuarter_LENIENT

import java.time.temporal.IsoFields; //导入依赖的package包/类
@Test(dataProvider = "parseLenientQuarter")
public void test_parse_parseLenientQuarter_LENIENT(String str, LocalDate expected, boolean smart) {
    DateTimeFormatter f = new DateTimeFormatterBuilder()
            .appendValue(YEAR).appendLiteral(':')
            .appendValue(IsoFields.QUARTER_OF_YEAR).appendLiteral(':')
            .appendValue(IsoFields.DAY_OF_QUARTER)
            .toFormatter().withResolverStyle(ResolverStyle.LENIENT);
    LocalDate parsed = LocalDate.parse(str, f);
    assertEquals(parsed, expected);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:TCKIsoFields.java

示例11: test_parse_weeks_STRICT

import java.time.temporal.IsoFields; //导入依赖的package包/类
@Test(dataProvider="week")
public void test_parse_weeks_STRICT(LocalDate date, DayOfWeek dow, int week, int wby) {
    DateTimeFormatter f = new DateTimeFormatterBuilder()
            .appendValue(IsoFields.WEEK_BASED_YEAR).appendLiteral('-')
            .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR).appendLiteral('-')
            .appendValue(DAY_OF_WEEK)
            .toFormatter().withResolverStyle(ResolverStyle.STRICT);
    LocalDate parsed = LocalDate.parse(wby + "-" + week + "-" + dow.getValue(), f);
    assertEquals(parsed, date);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:TCKIsoFields.java

示例12: test_parse_weeks_SMART

import java.time.temporal.IsoFields; //导入依赖的package包/类
@Test(dataProvider="week")
public void test_parse_weeks_SMART(LocalDate date, DayOfWeek dow, int week, int wby) {
    DateTimeFormatter f = new DateTimeFormatterBuilder()
            .appendValue(IsoFields.WEEK_BASED_YEAR).appendLiteral('-')
            .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR).appendLiteral('-')
            .appendValue(DAY_OF_WEEK)
            .toFormatter().withResolverStyle(ResolverStyle.SMART);
    LocalDate parsed = LocalDate.parse(wby + "-" + week + "-" + dow.getValue(), f);
    assertEquals(parsed, date);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:TCKIsoFields.java

示例13: test_parse_weeks_LENIENT

import java.time.temporal.IsoFields; //导入依赖的package包/类
@Test(dataProvider="week")
public void test_parse_weeks_LENIENT(LocalDate date, DayOfWeek dow, int week, int wby) {
    DateTimeFormatter f = new DateTimeFormatterBuilder()
            .appendValue(IsoFields.WEEK_BASED_YEAR).appendLiteral('-')
            .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR).appendLiteral('-')
            .appendValue(DAY_OF_WEEK)
            .toFormatter().withResolverStyle(ResolverStyle.LENIENT);
    LocalDate parsed = LocalDate.parse(wby + "-" + week + "-" + dow.getValue(), f);
    assertEquals(parsed, date);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:TCKIsoFields.java

示例14: test_parse_parseLenientWeek_STRICT

import java.time.temporal.IsoFields; //导入依赖的package包/类
@Test(dataProvider = "parseLenientWeek", expectedExceptions = DateTimeParseException.class)
public void test_parse_parseLenientWeek_STRICT(String str, LocalDate expected, boolean smart) {
    DateTimeFormatter f = new DateTimeFormatterBuilder()
            .appendValue(IsoFields.WEEK_BASED_YEAR).appendLiteral(':')
            .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR).appendLiteral(':')
            .appendValue(DAY_OF_WEEK)
            .toFormatter().withResolverStyle(ResolverStyle.STRICT);
    LocalDate.parse(str, f);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:TCKIsoFields.java

示例15: test_parse_parseLenientWeek_LENIENT

import java.time.temporal.IsoFields; //导入依赖的package包/类
@Test(dataProvider = "parseLenientWeek")
public void test_parse_parseLenientWeek_LENIENT(String str, LocalDate expected, boolean smart) {
    DateTimeFormatter f = new DateTimeFormatterBuilder()
            .appendValue(IsoFields.WEEK_BASED_YEAR).appendLiteral(':')
            .appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR).appendLiteral(':')
            .appendValue(DAY_OF_WEEK)
            .toFormatter().withResolverStyle(ResolverStyle.LENIENT);
    LocalDate parsed = LocalDate.parse(str, f);
    assertEquals(parsed, expected);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:TCKIsoFields.java


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