- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.threeten.bp.YearMonth
类的一些代码示例,展示了YearMonth
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YearMonth
类的具体详情如下:
包路径:org.threeten.bp.YearMonth
类名称:YearMonth
[英]A year-month in the ISO-8601 calendar system, such as 2007-12.
YearMonth is an immutable date-time object that represents the combination of a year and month. Any field that can be derived from a year and month, such as quarter-of-year, can be obtained.
This class does not store or represent a day, time or time-zone. For example, the value "October 2007" can be stored in a YearMonth.
The ISO-8601 calendar system is the modern civil calendar system used today in most of the world. It is equivalent to the proleptic Gregorian calendar system, in which today's rules for leap years are applied for all time. For most applications written today, the ISO-8601 rules are entirely suitable. However, any application that makes use of historical dates, and requires them to be accurate will find the ISO-8601 approach unsuitable.
This class is immutable and thread-safe.
[中]ISO-8601日历系统中的一年一月,如2007-12。
YearMonth是一个不可变的日期时间对象,表示年和月的组合。可以获得任何可以从一年和一个月派生的字段,例如一年的季度。
此类不存储或表示日期、时间或时区。例如,值“2007年10月”可以存储在YearMonth中。
ISO-8601日历系统是当今世界大部分地区使用的现代民用日历系统。它相当于公历的前身,即今天的闰年规则一直适用。对于今天编写的大多数应用程序,ISO-8601规则完全适用。然而,任何使用历史日期并要求其准确的应用程序都会发现ISO-8601方法不合适。
####实施者规范
这个类是不可变的,是线程安全的。
代码示例来源:origin: stackoverflow.com
val yearMonth = new YearMonth();
val formatter = DateTimeFormat.forPattern("yyyyMM");
val dates = (0 to 5).map {
i=>formatter.print(yearMonth.plusMonths(i)).toInt
}.toList
代码示例来源:origin: stackoverflow.com
YearMonth ym = YearMonth.of(2000, 2);
System.out.println(ym.lengthOfMonth()); //29 as expected
代码示例来源:origin: org.threeten/threetenbp
/**
* Combines this year with a month to create a {@code YearMonth}.
* <p>
* This returns a {@code YearMonth} formed from this year and the specified month.
* All possible combinations of year and month are valid.
* <p>
* This method can be used as part of a chain to produce a date:
* <pre>
* LocalDate date = year.atMonth(month).atDay(day);
* </pre>
*
* @param month the month-of-year to use, not null
* @return the year-month formed from this year and the specified month, not null
*/
public YearMonth atMonth(Month month) {
return YearMonth.of(year, month);
}
代码示例来源:origin: stackoverflow.com
YearMonth yearMonth = new YearMonth();
yearMonth.toLocalDate(1).dayOfMonth().getMaximumValue();
代码示例来源:origin: stackoverflow.com
public List<LocalDate> getDateRange(YearMonth yearMonth){
List<LocalDate> dateRange = new ArrayList<>();
IntStream.of(yearMonth.lengthOfMonth()).foreach(day -> dateRange.add(yearMonth.at(day));
return dateRange
}
代码示例来源:origin: stackoverflow.com
YearMonth ym = new YearMonth();
dt = ym.toDateTime(null);
System.out.println(dt.dayOfMonth().getMaximumValue());
代码示例来源:origin: ThreeTen/threetenbp
f.checkValidValue(newValue);
switch (f) {
case MONTH_OF_YEAR: return withMonth((int) newValue);
case PROLEPTIC_MONTH: return plusMonths(newValue - getLong(PROLEPTIC_MONTH));
case YEAR_OF_ERA: return withYear((int) (year < 1 ? 1 - newValue : newValue));
case YEAR: return withYear((int) newValue);
case ERA: return (getLong(ERA) == newValue ? this : withYear(1 - year));
代码示例来源:origin: com.github.joschi.jackson/jackson-datatype-threetenbp
@Override
public void serialize(YearMonth yearMonth, JsonGenerator generator, SerializerProvider provider) throws IOException
{
if (useTimestamp(provider)) {
generator.writeStartArray();
generator.writeNumber(yearMonth.getYear());
generator.writeNumber(yearMonth.getMonthValue());
generator.writeEndArray();
} else {
String str = (_formatter == null) ? yearMonth.toString() : yearMonth.format(_formatter);
generator.writeString(str);
}
}
代码示例来源:origin: org.threeten/threetenbp
YearMonth end = YearMonth.from(endExclusive);
if (unit instanceof ChronoUnit) {
long monthsUntil = end.getProlepticMonth() - getProlepticMonth(); // no overflow
switch ((ChronoUnit) unit) {
case MONTHS: return monthsUntil;
case CENTURIES: return monthsUntil / 1200;
case MILLENNIA: return monthsUntil / 12000;
case ERAS: return end.getLong(ERA) - getLong(ERA);
代码示例来源:origin: com.github.joschi.jackson/jackson-datatype-threetenbp
return YearMonth.parse(string, _formatter);
} catch (DateTimeException e) {
_rethrowDateTimeException(parser, context, e, string);
"Expected array to end.");
return YearMonth.of(year, month);
代码示例来源:origin: stackoverflow.com
import org.joda.time.YearMonth;
import java.util.Locale;
public class X {
public static void main(String[] s){
for (int i = 1;i<13; i++) {
YearMonth md = new YearMonth(1992, i);
System.out.println(md.monthOfYear().getAsText(new Locale("ru")));
}
}
}
代码示例来源:origin: stackoverflow.com
YearMonth yearMonth = new YearMonth (1970, 1);
Interval interval = yearMonth.toInterval(DateTimeZone.UTC);
int startSSE = (int) TimeUnit.MILLISECONDS.toSeconds(interval.getStartMillis());
int endSSE = (int) TimeUnit.MILLISECONDS.toSeconds(interval.getEndMillis());
System.out.printf("%d -> %d (%4.6f days)\n", startSSE, endSSE, ((float)(endSSE-startSSE))/(24*60*60));
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) {
System.out.println(mapToCurrentCentury(16, 11));
System.out.println(mapToCurrentCentury(116, 11));
System.out.println(mapToCurrentCentury(1116, 11));
}
private static YearMonth mapToCurrentCentury(int year, int month) {
if(year < 1000) {
YearMonth now = YearMonth.now();
return now.withYear(((now.get(ChronoField.YEAR) / 1000) * 1000) + (year % 1000)).withMonth(month);
}
else {
return YearMonth.of(year, month);
}
}
代码示例来源:origin: ThreeTen/threetenbp
/**
* Obtains an instance of {@code YearMonth} from a text string such as {@code 2007-12}.
* <p>
* The string must represent a valid year-month.
* The format must be {@code yyyy-MM}.
* Years outside the range 0000 to 9999 must be prefixed by the plus or minus symbol.
*
* @param text the text to parse such as "2007-12", not null
* @return the parsed year-month, not null
* @throws DateTimeParseException if the text cannot be parsed
*/
public static YearMonth parse(CharSequence text) {
return parse(text, PARSER);
}
代码示例来源:origin: org.threeten/threetenbp
/**
* Gets the range of valid values for the specified field.
* <p>
* The range object expresses the minimum and maximum valid values for a field.
* This year-month is used to enhance the accuracy of the returned range.
* If it is not possible to return the range, because the field is not supported
* or for some other reason, an exception is thrown.
* <p>
* If the field is a {@link ChronoField} then the query is implemented here.
* The {@link #isSupported(TemporalField) supported fields} will return
* appropriate range instances.
* All other {@code ChronoField} instances will throw a {@code DateTimeException}.
* <p>
* If the field is not a {@code ChronoField}, then the result of this method
* is obtained by invoking {@code TemporalField.rangeRefinedBy(TemporalAccessor)}
* passing {@code this} as the argument.
* Whether the range can be obtained is determined by the field.
*
* @param field the field to query the range for, not null
* @return the range of valid values for the field, not null
* @throws DateTimeException if the range for the field cannot be obtained
*/
@Override
public ValueRange range(TemporalField field) {
if (field == YEAR_OF_ERA) {
return (getYear() <= 0 ? ValueRange.of(1, Year.MAX_VALUE + 1) : ValueRange.of(1, Year.MAX_VALUE));
}
return super.range(field);
}
代码示例来源:origin: ThreeTen/threetenbp
/**
* Is this year-month after the specified year-month.
*
* @param other the other year-month to compare to, not null
* @return true if this is after the specified year-month
*/
public boolean isAfter(YearMonth other) {
return compareTo(other) > 0;
}
代码示例来源:origin: ThreeTen/threetenbp
@Override
public YearMonth queryFrom(TemporalAccessor temporal) {
return YearMonth.from(temporal);
}
};
代码示例来源:origin: org.threeten/threetenbp
f.checkValidValue(newValue);
switch (f) {
case MONTH_OF_YEAR: return withMonth((int) newValue);
case PROLEPTIC_MONTH: return plusMonths(newValue - getLong(PROLEPTIC_MONTH));
case YEAR_OF_ERA: return withYear((int) (year < 1 ? 1 - newValue : newValue));
case YEAR: return withYear((int) newValue);
case ERA: return (getLong(ERA) == newValue ? this : withYear(1 - year));
代码示例来源:origin: ThreeTen/threetenbp
YearMonth end = YearMonth.from(endExclusive);
if (unit instanceof ChronoUnit) {
long monthsUntil = end.getProlepticMonth() - getProlepticMonth(); // no overflow
switch ((ChronoUnit) unit) {
case MONTHS: return monthsUntil;
case CENTURIES: return monthsUntil / 1200;
case MILLENNIA: return monthsUntil / 12000;
case ERAS: return end.getLong(ERA) - getLong(ERA);
代码示例来源:origin: org.threeten/threetenbp
/**
* Obtains an instance of {@code YearMonth} from a text string such as {@code 2007-12}.
* <p>
* The string must represent a valid year-month.
* The format must be {@code yyyy-MM}.
* Years outside the range 0000 to 9999 must be prefixed by the plus or minus symbol.
*
* @param text the text to parse such as "2007-12", not null
* @return the parsed year-month, not null
* @throws DateTimeParseException if the text cannot be parsed
*/
public static YearMonth parse(CharSequence text) {
return parse(text, PARSER);
}
我在某些摩托罗拉设备上有一个非常奇怪的行为,其中 LocalDateTime.now() 返回 0000-00-00T00:00:00.0 和 ThreeTenABP . 代码如下: @Overrid
本文整理了Java中org.threeten.bp.ZoneId类的一些代码示例,展示了ZoneId类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从
本文整理了Java中org.threeten.bp.ZonedDateTime类的一些代码示例,展示了ZonedDateTime类的具体用法。这些代码示例主要来源于Github/Stackoverfl
本文整理了Java中org.threeten.bp.ZoneOffset类的一些代码示例,展示了ZoneOffset类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Mav
本文整理了Java中org.threeten.bp.YearMonth类的一些代码示例,展示了YearMonth类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven
本文整理了Java中org.threeten.bp.Year类的一些代码示例,展示了Year类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选
本文整理了Java中org.threeten.extra.YearQuarter类的一些代码示例,展示了YearQuarter类的具体用法。这些代码示例主要来源于Github/Stackoverflo
我正在使用 ThreeTen 并尝试格式化 Instant。拆分它会更容易,但我很好奇,这应该有效吗?从我读过的所有内容来看,Instant 应该是可解析的,并且具有模式的所有组件: @Test pu
这个痕迹对任何人来说都很眼熟吗?它只发生在少数设备上。 ThreeTenBP 是依赖中的依赖。 10:16:33 E AndroidRuntime : java.util.ServiceConfigu
本文整理了Java中org.threeten.bp.ZoneId.of()方法的一些代码示例,展示了ZoneId.of()的具体用法。这些代码示例主要来源于Github/Stackoverflow/M
本文整理了Java中org.threeten.bp.ZonedDateTime.from()方法的一些代码示例,展示了ZonedDateTime.from()的具体用法。这些代码示例主要来源于Gith
本文整理了Java中org.threeten.bp.zone.ZoneRulesProvider类的一些代码示例,展示了ZoneRulesProvider类的具体用法。这些代码示例主要来源于Githu
本文整理了Java中org.threeten.bp.zone.ZoneRules类的一些代码示例,展示了ZoneRules类的具体用法。这些代码示例主要来源于Github/Stackoverflow/
本文整理了Java中org.threeten.bp.ZoneOffset.of()方法的一些代码示例,展示了ZoneOffset.of()的具体用法。这些代码示例主要来源于Github/Stackov
本文整理了Java中org.threeten.bp.YearMonth.of()方法的一些代码示例,展示了YearMonth.of()的具体用法。这些代码示例主要来源于Github/Stackover
本文整理了Java中org.threeten.bp.Year.of()方法的一些代码示例,展示了Year.of()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven
本文整理了Java中org.threeten.bp.zone.ZoneRulesInitializer类的一些代码示例,展示了ZoneRulesInitializer类的具体用法。这些代码示例主要来源
本文整理了Java中org.threeten.bp.zone.ZoneOffsetTransition类的一些代码示例,展示了ZoneOffsetTransition类的具体用法。这些代码示例主要来源
本文整理了Java中org.threeten.bp.zone.ZoneOffsetTransitionRule类的一些代码示例,展示了ZoneOffsetTransitionRule类的具体用法。这些
我使用 this library用于在我的应用程序中存储日期和时间相关数据。当应用程序启动时,AndroidThreeTen 首先被初始化以正常运行。所以想问下单元测试的时候怎么初始化呢?例如。我想使
我是一名优秀的程序员,十分优秀!