本文整理了Java中cesiumlanguagewriter.YearMonthDay.isValidDate()
方法的一些代码示例,展示了YearMonthDay.isValidDate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YearMonthDay.isValidDate()
方法的具体详情如下:
包路径:cesiumlanguagewriter.YearMonthDay
类名称:YearMonthDay
方法名:isValidDate
[英]Indicates whether the year, month, and day are a valid representation.
[中]
代码示例来源:origin: AnalyticalGraphicsInc/czml-writer
/**
*
Initializes a {@link YearMonthDay} from the provided values.
* @param year The year.
* @param month The month of the year (in the range 1 through 12)
* @param day The day of the month (in the range 1 through the number of
days in {@code month})
* @exception ArgumentException
Thrown when the {@code year}, {@code month}, or
{@code day} is outside of its acceptable range.
*/
public YearMonthDay(int year, int month, int day) {
if (!isValidDate(year, month, day)) {
throw new ArgumentException(CesiumLocalization.getYearMonthDayInvalidArgument());
}
// fields are stored zero-indexed
m_year = year - 1;
m_month = month - 1;
m_day = day - 1;
}
代码示例来源:origin: AnalyticalGraphicsInc/czml-writer
m_month--;
m_day--;
if (!isValidDate(m_year + 1, m_month + 1, m_day + 1)) {
throw new ArgumentOutOfRangeException(CesiumLocalization.getYearMonthDayInvalidArgument());
代码示例来源:origin: AnalyticalGraphicsInc/czml-writer
Assert.assertFalse(YearMonthDay.isValidDate(2000, 0, 1));
Assert.assertTrue(YearMonthDay.isValidDate(2000, 1, 1));
Assert.assertTrue(YearMonthDay.isValidDate(2000, 2, 1));
Assert.assertTrue(YearMonthDay.isValidDate(2000, 3, 1));
Assert.assertTrue(YearMonthDay.isValidDate(2000, 4, 1));
Assert.assertTrue(YearMonthDay.isValidDate(2000, 5, 1));
Assert.assertTrue(YearMonthDay.isValidDate(2000, 6, 1));
Assert.assertTrue(YearMonthDay.isValidDate(2000, 7, 1));
Assert.assertTrue(YearMonthDay.isValidDate(2000, 8, 1));
Assert.assertTrue(YearMonthDay.isValidDate(2000, 9, 1));
Assert.assertTrue(YearMonthDay.isValidDate(2000, 10, 1));
Assert.assertTrue(YearMonthDay.isValidDate(2000, 11, 1));
Assert.assertTrue(YearMonthDay.isValidDate(2000, 12, 1));
Assert.assertFalse(YearMonthDay.isValidDate(2000, 13, 1));
for (int month = 1; month < 13; ++month) {
int daysInMonth = YearMonthDay.daysInMonth(2000, month);
Assert.assertFalse(YearMonthDay.isValidDate(2000, month, 0));
for (int day = 1; day < daysInMonth + 1; ++day) {
Assert.assertTrue(YearMonthDay.isValidDate(2000, month, day));
Assert.assertFalse(YearMonthDay.isValidDate(2000, month, daysInMonth + 1));
代码示例来源:origin: AnalyticalGraphicsInc/czml-writer
return false;
if (!YearMonthDay.isValidDate(year, month, day)) {
return false;
代码示例来源:origin: AnalyticalGraphicsInc/czml-writer
/**
*
Initializes a {@link YearMonthDay} from the provided values.
* @param year The year.
* @param dayOfYear The day of the year
(in the range 1 through the number of days in the year).
*/
public YearMonthDay(int year, int dayOfYear) {
if (dayOfYear > daysInYear(year)) {
throw new ArgumentException(CesiumLocalization.getYearMonthDayInvalidArgument(), "dayOfYear");
}
// year is stored zero-indexed
m_year = year - 1;
int[] cumulativeMonthTable = getCumulativeMonthTable(year);
// month is stored zero-indexed
for (m_month = 11; m_month > 0; --m_month) {
if (cumulativeMonthTable[m_month] < dayOfYear) {
break;
}
}
// day is stored zero-indexed
m_day = dayOfYear - cumulativeMonthTable[m_month] - 1;
if (!isValidDate(m_year + 1, m_month + 1, m_day + 1)) {
throw new ArgumentException(CesiumLocalization.getYearMonthDayInvalidArgument());
}
}
内容来源于网络,如有侵权,请联系作者删除!