本文整理了Java中com.datastax.driver.core.LocalDate.isoCalendar()
方法的一些代码示例,展示了LocalDate.isoCalendar()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LocalDate.isoCalendar()
方法的具体详情如下:
包路径:com.datastax.driver.core.LocalDate
类名称:LocalDate
方法名:isoCalendar
暂无
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
private GregorianCalendar getCalendar() {
// Two threads can race and both create a calendar. This is not a problem.
if (calendar == null) {
// Use a local variable to only expose after we're done mutating it.
GregorianCalendar tmp = isoCalendar();
tmp.setTimeInMillis(millisSinceEpoch);
calendar = tmp;
}
return calendar;
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
/**
* Return a new {@link LocalDate} with the specified (signed) amount of time added to (or
* subtracted from) the given {@link Calendar} field, based on the calendar's rules.
*
* <p>Note that adding any amount to a field smaller than {@link Calendar#DAY_OF_MONTH} will
* remain without effect, as this class does not keep time components.
*
* <p>See {@link Calendar} javadocs for more information.
*
* @param field a {@link Calendar} field to modify.
* @param amount the amount of date or time to be added to the field.
* @return a new {@link LocalDate} with the specified (signed) amount of time added to (or
* subtracted from) the given {@link Calendar} field.
* @throws IllegalArgumentException if the new date is not in the range [-5877641-06-23;
* 5881580-07-11].
*/
public LocalDate add(int field, int amount) {
GregorianCalendar newCalendar = isoCalendar();
newCalendar.setTimeInMillis(millisSinceEpoch);
newCalendar.add(field, amount);
LocalDate newDate = fromMillisSinceEpoch(newCalendar.getTimeInMillis());
newDate.calendar = newCalendar;
return newDate;
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
/**
* Builds a new instance from a year/month/day specification.
*
* <p>This method is not lenient, i.e. '2014-12-32' will not be treated as '2015-01-01', but
* instead throw an {@code IllegalArgumentException}.
*
* @param year the year in ISO format (see {@link LocalDate this class's Javadoc}).
* @param month the month. It is 1-based (e.g. 1 for January).
* @param dayOfMonth the day of the month.
* @return the new instance.
* @throws IllegalArgumentException if the corresponding date does not exist in the ISO8601
* calendar.
*/
public static LocalDate fromYearMonthDay(int year, int month, int dayOfMonth) {
int calendarYear = (year <= 0) ? -year + 1 : year;
int calendarEra = (year <= 0) ? GregorianCalendar.BC : GregorianCalendar.AD;
GregorianCalendar calendar = isoCalendar();
// We can't allow leniency because that could mess with our year shift above (for example if the
// arguments were 0, 12, 32)
calendar.setLenient(false);
calendar.clear();
calendar.set(calendarYear, month - 1, dayOfMonth, 0, 0, 0);
calendar.set(Calendar.ERA, calendarEra);
LocalDate date = fromMillisSinceEpoch(calendar.getTimeInMillis());
date.calendar = calendar;
return date;
}
代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver
private GregorianCalendar getCalendar() {
// Two threads can race and both create a calendar. This is not a problem.
if (calendar == null) {
// Use a local variable to only expose after we're done mutating it.
GregorianCalendar tmp = isoCalendar();
tmp.setTimeInMillis(millisSinceEpoch);
calendar = tmp;
}
return calendar;
}
代码示例来源:origin: com.yugabyte/cassandra-driver-core
private GregorianCalendar getCalendar() {
// Two threads can race and both create a calendar. This is not a problem.
if (calendar == null) {
// Use a local variable to only expose after we're done mutating it.
GregorianCalendar tmp = isoCalendar();
tmp.setTimeInMillis(millisSinceEpoch);
calendar = tmp;
}
return calendar;
}
代码示例来源:origin: io.prestosql.cassandra/cassandra-driver
private GregorianCalendar getCalendar() {
// Two threads can race and both create a calendar. This is not a problem.
if (calendar == null) {
// Use a local variable to only expose after we're done mutating it.
GregorianCalendar tmp = isoCalendar();
tmp.setTimeInMillis(millisSinceEpoch);
calendar = tmp;
}
return calendar;
}
代码示例来源:origin: com.yugabyte/cassandra-driver-core
/**
* Return a new {@link LocalDate} with the specified (signed) amount
* of time added to (or subtracted from) the given {@link Calendar} field,
* based on the calendar's rules.
* <p/>
* Note that adding any amount to a field smaller than
* {@link Calendar#DAY_OF_MONTH} will remain without effect,
* as this class does not keep time components.
* <p/>
* See {@link Calendar} javadocs for more information.
*
* @param field a {@link Calendar} field to modify.
* @param amount the amount of date or time to be added to the field.
* @return a new {@link LocalDate} with the specified (signed) amount
* of time added to (or subtracted from) the given {@link Calendar} field.
* @throws IllegalArgumentException if the new date is not in the range [-5877641-06-23; 5881580-07-11].
*/
public LocalDate add(int field, int amount) {
GregorianCalendar newCalendar = isoCalendar();
newCalendar.setTimeInMillis(millisSinceEpoch);
newCalendar.add(field, amount);
LocalDate newDate = fromMillisSinceEpoch(newCalendar.getTimeInMillis());
newDate.calendar = newCalendar;
return newDate;
}
代码示例来源:origin: io.prestosql.cassandra/cassandra-driver
/**
* Return a new {@link LocalDate} with the specified (signed) amount
* of time added to (or subtracted from) the given {@link Calendar} field,
* based on the calendar's rules.
* <p/>
* Note that adding any amount to a field smaller than
* {@link Calendar#DAY_OF_MONTH} will remain without effect,
* as this class does not keep time components.
* <p/>
* See {@link Calendar} javadocs for more information.
*
* @param field a {@link Calendar} field to modify.
* @param amount the amount of date or time to be added to the field.
* @return a new {@link LocalDate} with the specified (signed) amount
* of time added to (or subtracted from) the given {@link Calendar} field.
* @throws IllegalArgumentException if the new date is not in the range [-5877641-06-23; 5881580-07-11].
*/
public LocalDate add(int field, int amount) {
GregorianCalendar newCalendar = isoCalendar();
newCalendar.setTimeInMillis(millisSinceEpoch);
newCalendar.add(field, amount);
LocalDate newDate = fromMillisSinceEpoch(newCalendar.getTimeInMillis());
newDate.calendar = newCalendar;
return newDate;
}
代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver
/**
* Return a new {@link LocalDate} with the specified (signed) amount
* of time added to (or subtracted from) the given {@link Calendar} field,
* based on the calendar's rules.
* <p/>
* Note that adding any amount to a field smaller than
* {@link Calendar#DAY_OF_MONTH} will remain without effect,
* as this class does not keep time components.
* <p/>
* See {@link Calendar} javadocs for more information.
*
* @param field a {@link Calendar} field to modify.
* @param amount the amount of date or time to be added to the field.
* @return a new {@link LocalDate} with the specified (signed) amount
* of time added to (or subtracted from) the given {@link Calendar} field.
* @throws IllegalArgumentException if the new date is not in the range [-5877641-06-23; 5881580-07-11].
*/
public LocalDate add(int field, int amount) {
GregorianCalendar newCalendar = isoCalendar();
newCalendar.setTimeInMillis(millisSinceEpoch);
newCalendar.add(field, amount);
LocalDate newDate = fromMillisSinceEpoch(newCalendar.getTimeInMillis());
newDate.calendar = newCalendar;
return newDate;
}
代码示例来源:origin: io.prestosql.cassandra/cassandra-driver
/**
* Builds a new instance from a year/month/day specification.
* <p/>
* This method is not lenient, i.e. '2014-12-32' will not be treated as '2015-01-01', but
* instead throw an {@code IllegalArgumentException}.
*
* @param year the year in ISO format (see {@link LocalDate this class's Javadoc}).
* @param month the month. It is 1-based (e.g. 1 for January).
* @param dayOfMonth the day of the month.
* @return the new instance.
* @throws IllegalArgumentException if the corresponding date does not exist in the ISO8601
* calendar.
*/
public static LocalDate fromYearMonthDay(int year, int month, int dayOfMonth) {
int calendarYear = (year <= 0) ? -year + 1 : year;
int calendarEra = (year <= 0) ? GregorianCalendar.BC : GregorianCalendar.AD;
GregorianCalendar calendar = isoCalendar();
// We can't allow leniency because that could mess with our year shift above (for example if the arguments were 0, 12, 32)
calendar.setLenient(false);
calendar.clear();
calendar.set(calendarYear, month - 1, dayOfMonth, 0, 0, 0);
calendar.set(Calendar.ERA, calendarEra);
LocalDate date = fromMillisSinceEpoch(calendar.getTimeInMillis());
date.calendar = calendar;
return date;
}
代码示例来源:origin: com.yugabyte/cassandra-driver-core
/**
* Builds a new instance from a year/month/day specification.
* <p/>
* This method is not lenient, i.e. '2014-12-32' will not be treated as '2015-01-01', but
* instead throw an {@code IllegalArgumentException}.
*
* @param year the year in ISO format (see {@link LocalDate this class's Javadoc}).
* @param month the month. It is 1-based (e.g. 1 for January).
* @param dayOfMonth the day of the month.
* @return the new instance.
* @throws IllegalArgumentException if the corresponding date does not exist in the ISO8601
* calendar.
*/
public static LocalDate fromYearMonthDay(int year, int month, int dayOfMonth) {
int calendarYear = (year <= 0) ? -year + 1 : year;
int calendarEra = (year <= 0) ? GregorianCalendar.BC : GregorianCalendar.AD;
GregorianCalendar calendar = isoCalendar();
// We can't allow leniency because that could mess with our year shift above (for example if the arguments were 0, 12, 32)
calendar.setLenient(false);
calendar.clear();
calendar.set(calendarYear, month - 1, dayOfMonth, 0, 0, 0);
calendar.set(Calendar.ERA, calendarEra);
LocalDate date = fromMillisSinceEpoch(calendar.getTimeInMillis());
date.calendar = calendar;
return date;
}
代码示例来源:origin: com.facebook.presto.cassandra/cassandra-driver
/**
* Builds a new instance from a year/month/day specification.
* <p/>
* This method is not lenient, i.e. '2014-12-32' will not be treated as '2015-01-01', but
* instead throw an {@code IllegalArgumentException}.
*
* @param year the year in ISO format (see {@link LocalDate this class's Javadoc}).
* @param month the month. It is 1-based (e.g. 1 for January).
* @param dayOfMonth the day of the month.
* @return the new instance.
* @throws IllegalArgumentException if the corresponding date does not exist in the ISO8601
* calendar.
*/
public static LocalDate fromYearMonthDay(int year, int month, int dayOfMonth) {
int calendarYear = (year <= 0) ? -year + 1 : year;
int calendarEra = (year <= 0) ? GregorianCalendar.BC : GregorianCalendar.AD;
GregorianCalendar calendar = isoCalendar();
// We can't allow leniency because that could mess with our year shift above (for example if the arguments were 0, 12, 32)
calendar.setLenient(false);
calendar.clear();
calendar.set(calendarYear, month - 1, dayOfMonth, 0, 0, 0);
calendar.set(Calendar.ERA, calendarEra);
LocalDate date = fromMillisSinceEpoch(calendar.getTimeInMillis());
date.calendar = calendar;
return date;
}
内容来源于网络,如有侵权,请联系作者删除!