本文整理了Java中java.time.YearMonth.<init>()
方法的一些代码示例,展示了YearMonth.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YearMonth.<init>()
方法的具体详情如下:
包路径:java.time.YearMonth
类名称:YearMonth
方法名:<init>
[英]Constructor.
[中]建造师。
代码示例来源:origin: com.github.seratch/java-time-backport
/**
* Returns a copy of this year-month with the new year and month, checking
* to see if a new object is in fact required.
*
* @param newYear the year to represent, validated from MIN_YEAR to MAX_YEAR
* @param newMonth the month-of-year to represent, validated not null
* @return the year-month, not null
*/
private YearMonth with(int newYear, int newMonth) {
if (year == newYear && month == newMonth) {
return this;
}
return new YearMonth(newYear, newMonth);
}
代码示例来源:origin: stackoverflow.com
// TODO: Which time zone are you interested in?
YearMonth yearMonth = new YearMonth();
DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyyMM");
List<String> dates = new ArrayList<>();
for (int i = 0; i < 6; i++) {
dates.add(formatter.print(yearMonth.plusMonths(i)));
}
代码示例来源:origin: stackoverflow.com
YearMonth date = new YearMonth("2014-01");
date = date.minusMonths(1); //will equal 2013-11
代码示例来源:origin: com.github.seratch/java-time-backport
/**
* Obtains an instance of {@code YearMonth} from a year and month.
*
* @param year the year to represent, from MIN_YEAR to MAX_YEAR
* @param month the month-of-year to represent, from 1 (January) to 12 (December)
* @return the year-month, not null
* @throws DateTimeException if either field value is invalid
*/
public static YearMonth of(int year, int month) {
YEAR.checkValidValue(year);
MONTH_OF_YEAR.checkValidValue(month);
return new YearMonth(year, month);
}
代码示例来源:origin: stackoverflow.com
String input = "2014-02";
YearMonth yearMonth = YearMonth.parse( input ); // Construct by parsing string.
int year = yearMonth.getYear();
int month = yearMonth.getMonthOfYear();
String output = yearMonth.toString(); // Joda-Time uses ISO 8601 formats by default for generating strings.
YearMonth yearMonth2 = new YearMonth( year , month ); // Construct by passing numbers for year and month.
内容来源于网络,如有侵权,请联系作者删除!