org.joda.time.DateTime.dayOfMonth()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(318)

本文整理了Java中org.joda.time.DateTime.dayOfMonth()方法的一些代码示例,展示了DateTime.dayOfMonth()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DateTime.dayOfMonth()方法的具体详情如下:
包路径:org.joda.time.DateTime
类名称:DateTime
方法名:dayOfMonth

DateTime.dayOfMonth介绍

[英]Get the day of month property which provides access to advanced functionality.
[中]获取提供高级功能访问权限的day of month属性。

代码示例

代码示例来源:origin: stackoverflow.com

public static int daysOfMonth(int year, int month) {
 DateTime dateTime = new DateTime(year, month, 14, 12, 0, 0, 000);
 return dateTime.dayOfMonth().getMaximumValue();
}

代码示例来源:origin: apache/incubator-druid

/**
 * Calcite expects "DATE" types to be number of days from the epoch to the UTC date matching the local time fields.
 *
 * @param dateTime joda timestamp
 * @param timeZone session time zone
 *
 * @return Calcite style date
 */
public static int jodaToCalciteDate(final DateTime dateTime, final DateTimeZone timeZone)
{
 final DateTime date = dateTime.withZone(timeZone).dayOfMonth().roundFloorCopy();
 return Days.daysBetween(DateTimes.EPOCH, date.withZoneRetainFields(DateTimeZone.UTC)).getDays();
}

代码示例来源:origin: apache/incubator-druid

@Test
public void testTimestampsInResponseLosAngelesTimeZone() throws Exception
{
 final ResultSet resultSet = clientLosAngeles.createStatement().executeQuery(
   "SELECT __time, CAST(__time AS DATE) AS t2 FROM druid.foo LIMIT 1"
 );
 final DateTimeZone timeZone = DateTimes.inferTzFromString("America/Los_Angeles");
 final DateTime localDateTime = new DateTime("2000-01-01T00Z", timeZone);
 final List<Map<String, Object>> resultRows = getRows(resultSet);
 Assert.assertEquals(
   ImmutableList.of(
     ImmutableMap.of(
       "__time", new Timestamp(Calcites.jodaToCalciteTimestamp(localDateTime, timeZone)),
       "t2", new Date(Calcites.jodaToCalciteTimestamp(localDateTime.dayOfMonth().roundFloorCopy(), timeZone))
     )
   ),
   resultRows
 );
}

代码示例来源:origin: apache/incubator-pinot

case DAYS:
 _dateTimeTruncate = (dateTime) -> _outputDateTimeFormatter
   .print(dateTime.withDayOfMonth((dateTime.getDayOfMonth() / sz) * sz).dayOfMonth().roundFloorCopy());
 break;
default:

代码示例来源:origin: stackoverflow.com

DateTimeZone timeZone = DateTimeZone.forID( "Europe/Paris" );
// Usually better to specify a time zone rather than rely on default.
DateTime now = new DateTime( timeZone ); // Or, for default time zone: new DateTime()
DateTime monthFromNow = now.plusMonths(1);
DateTime firstOfNextMonth = monthFromNow.dayOfMonth().withMinimumValue();
DateTime firstMomentOfFirstOfNextMonth = firstOfNextMonth.withTimeAtStartOfDay();

代码示例来源:origin: BroadleafCommerce/BroadleafCommerce

try {
  DateTime expirationDate = new DateTime(Integer.parseInt("20" + expYear), Integer.parseInt(expMonth), 1, 0, 0);
  expirationDate = expirationDate.dayOfMonth().withMaximumValue();
  validDate = expirationDate.isAfterNow();
  validDateFormat = true;

代码示例来源:origin: stackoverflow.com

DateTime now = new DateTime();      
DateTime dt = now.dayOfMonth().withMaximumValue().withDayOfWeek(DateTimeConstants.FRIDAY);
if (dt.getMonthOfYear() != now.getMonthOfYear()) {
 dt = dt.minusDays(7);
}       
System.out.println(dt);

代码示例来源:origin: ihaolin/antares

/**
 * 获得当前月的最后一天
 * @param date 日期
 * @return 当前月的最后一天
 */
public static Date endDateOfMonth(Date date) {
  DateTime dateTime = new DateTime(date);
  return dateTime.dayOfMonth().withMaximumValue().toDate();
}

代码示例来源:origin: ihaolin/antares

/**
 * 获得当前月的第一天
 * @param date 日期
 * @return 当前月的第一天
 */
public static Date startDateOfMonth(Date date) {
  DateTime dateTime = new DateTime(date);
  return dateTime.dayOfMonth().withMinimumValue().toDate();
}

代码示例来源:origin: stackoverflow.com

DateTime dateTime = new DateTime().withWeekOfWeekyear(i).withDayOfWeek(DateTimeConstants.MONDAY);
   if (dateTime.dayOfMonth().getMaximumValue() - dateTime.dayOfMonth().get() < 3) {
     dateTime = dateTime.plusMonths(1);
   }
   int month = dateTime.monthOfYear().get();

代码示例来源:origin: org.hsweb/hsweb-commons

/**
 * 计算当月有几天
 *
 * @param date
 * @return
 */
public static int getDateOfMonth(Date date) {
  DateTime dateTime = new DateTime(date);
  return dateTime.dayOfMonth().getMaximumValue();
}

代码示例来源:origin: org.apache.isis/applib

private void checkDate(final int year, final int month, final int day) {
  if ((month < 1) || (month > 12)) {
    throw new IllegalArgumentException("Month must be in the range 1 - 12 inclusive");
  }
  final DateTime newDate = newDateTime(year, month, 1);
  final int lastDayOfMonth = newDate.dayOfMonth().getMaximumValue();
  ;
  if ((day < 1) || (day > lastDayOfMonth)) {
    throw new IllegalArgumentException("Day must be in the range 1 - " + lastDayOfMonth + " inclusive: " + day);
  }
}

代码示例来源:origin: org.apache.isis.core/isis-core-applib

private void checkDate(final int year, final int month, final int day) {
  if ((month < 1) || (month > 12)) {
    throw new IllegalArgumentException("Month must be in the range 1 - 12 inclusive");
  }
  final DateTime newDate = newDateTime(year, month, 1);
  final int lastDayOfMonth = newDate.dayOfMonth().getMaximumValue();
  ;
  if ((day < 1) || (day > lastDayOfMonth)) {
    throw new IllegalArgumentException("Day must be in the range 1 - " + lastDayOfMonth + " inclusive: " + day);
  }
}

代码示例来源:origin: org.apache.isis/applib

/**
 * Calculates, and returns, a date representing the first day of the month
 * relative to the current date.
 */
public Date startOfMonth() {
  return new Date(date.dayOfMonth().withMinimumValue());
}

代码示例来源:origin: org.wicketstuff/wicketstuff-calendarviews

public static TimePeriod createMonthViewDates(int month, int year)
{
  Date start = new DateTime().dayOfMonth()
    .setCopy(1)
    .monthOfYear()
    .setCopy(month)
    .year()
    .setCopy(year)
    .toDate();
  Date end = new DateTime(start).plusMonths(1).minusDays(1).toDate();
  return new TimePeriod(start, end);
}

代码示例来源:origin: addthis/hydra

private static String replaceDateElements(DateTime time, String template) {
  String result = YY_PATTERN.matcher(template).replaceAll(time.year().getAsString());
  result = Y_PATTERN.matcher(result).replaceAll(getTwoDigit(time.year().get()));
  result = M_PATTERN.matcher(result).replaceAll(getTwoDigit(time.monthOfYear().get()));
  result = D_PATTERN.matcher(result).replaceAll(getTwoDigit(time.dayOfMonth().get()));
  result = H_PATTERN.matcher(result).replaceAll(getTwoDigit(time.hourOfDay().get()));
  log.debug("template={}, result={}", template, result);
  return result;
}

代码示例来源:origin: chengzhx76/weixin-shop-spring-cloud

@Override
public List<BonusPointRecord> getByUserIdAndCurrentMonth(String userId) {
  Date currentMonth = DateTime.now().dayOfMonth().withMinimumValue().hourOfDay().withMinimumValue().millisOfDay().withMinimumValue().toDate();
  BonusPointRecord bonusPointRecord = new BonusPointRecord();
  bonusPointRecord.setAccountId(userId);
  bonusPointRecord.setCreateDate(currentMonth);
  return bonusPointRecordDao.loadByUSerIdAndCurrentMonth(bonusPointRecord);
}

代码示例来源:origin: org.springframework.analytics/spring-analytics

private long[] getDayCountsForMonth(String name, DateTime month) {
  AggregateKeyGenerator akg = new AggregateKeyGenerator(
      AGGREGATE_COUNTER_KEY_PREFIX, name, month.withTimeAtStartOfDay());
  return convertToArray(getEntries(akg.getMonthKey()), month.dayOfMonth().getMaximumValue(), true); // Days in this month
}

代码示例来源:origin: org.opensingular/singular-server-commons

private static String errorCode() {
  DateTime now = DateTime.now();
  return format("SER-%04d-%02d%02d%02d-%02d%02d-%04d ",
      get(now.year()), get(now.monthOfYear()), get(now.dayOfMonth()),
      get(now.hourOfDay()), get(now.minuteOfHour()), get(now.secondOfMinute()),
      get(now.millisOfSecond()));
}

代码示例来源:origin: org.opencds.cqf/cql-engine

public static DateTime fromJodaDateTime(org.joda.time.DateTime dt) {
  int [] values = { dt.year().get(), dt.monthOfYear().get(), dt.dayOfMonth().get(), dt.hourOfDay().get(),
      dt.minuteOfHour().get(), dt.secondOfMinute().get(), dt.millisOfSecond().get() };
  return new DateTime(new Partial(fields, values), dt.getZone());
}

相关文章

DateTime类方法