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

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

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

DateTime.getHourOfDay介绍

暂无

代码示例

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

DateTime dt = new DateTime();  // current time
int month = dt.getMonth();     // gets the current month
int hours = dt.getHourOfDay(); // gets hour of day

代码示例来源:origin: Graylog2/graylog2-server

private static Map<String, Object> ingestTimeFields(DateTime ingestTime) {
  return ImmutableMap.<String, Object>builder()
      .put("ingest_time", ingestTime.toString())
      .put("ingest_time_epoch", ingestTime.getMillis())
      .put("ingest_time_second", ingestTime.getSecondOfMinute())
      .put("ingest_time_minute", ingestTime.getMinuteOfHour())
      .put("ingest_time_hour", ingestTime.getHourOfDay())
      .put("ingest_time_day", ingestTime.getDayOfMonth())
      .put("ingest_time_month", ingestTime.getMonthOfYear())
      .put("ingest_time_year", ingestTime.getYear())
      .build();
}

代码示例来源:origin: GitLqr/LQRWeChat

@NonNull
private static String getTime(DateTime msgTime) {
  int hourOfDay = msgTime.getHourOfDay();
  String when;
  if (hourOfDay >= 18) {//18-24
    when = "晚上";
  } else if (hourOfDay >= 13) {//13-18
    when = "下午";
  } else if (hourOfDay >= 11) {//11-13
    when = "中午";
  } else if (hourOfDay >= 5) {//5-11
    when = "早上";
  } else {//0-5
    when = "凌晨";
  }
  return when + " " + msgTime.toString("hh:mm");
}

代码示例来源:origin: alibaba/canal

dateTime = new DateTime(((Date) val).getTime());
if (dateTime.getHourOfDay() == 0 && dateTime.getMinuteOfHour() == 0 && dateTime.getSecondOfMinute() == 0
  && dateTime.getMillisOfSecond() == 0) {
  res = dateTime.toString("yyyy-MM-dd");
if (dateTime.getHourOfDay() == 0 && dateTime.getMinuteOfHour() == 0 && dateTime.getSecondOfMinute() == 0
  && dateTime.getMillisOfSecond() == 0) {
  res = dateTime.toString("yyyy-MM-dd");

代码示例来源:origin: prestodb/presto

@Test
public void testTimeZone()
{
  assertFunction("hour(" + TIMESTAMP_LITERAL + ")", BIGINT, (long) TIMESTAMP.getHourOfDay());
  assertFunction("minute(" + TIMESTAMP_LITERAL + ")", BIGINT, (long) TIMESTAMP.getMinuteOfHour());
  assertFunction("hour(" + WEIRD_TIMESTAMP_LITERAL + ")", BIGINT, (long) WEIRD_TIMESTAMP.getHourOfDay());
  assertFunction("minute(" + WEIRD_TIMESTAMP_LITERAL + ")", BIGINT, (long) WEIRD_TIMESTAMP.getMinuteOfHour());
  assertFunction("current_timezone()", VARCHAR, TIME_ZONE_KEY.getId());
}

代码示例来源:origin: apache/drill

@Test
public void testDateTimeHoursMinutesSecondsFormat() {
 String day = "24";
 String month = "June";
 int year = 2010;
 int hours = 10;
 int minutes = 12;
 DateTime date = parseDateFromPostgres(year + "" + day + month + hours + ":" + minutes + "am", "YYYYDDFMMonthHH12:MIam");
 Assert.assertTrue(date.getDayOfMonth() == Integer.parseInt(day) &&
           date.getMonthOfYear() == 6 &&
           date.getYear() == year &&
           date.getHourOfDay() == hours &&
           date.getMinuteOfHour() == minutes);
}

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

case HOURS:
 _dateTimeTruncate = (dateTime) -> _outputDateTimeFormatter
   .print(dateTime.withHourOfDay((dateTime.getHourOfDay() / sz) * sz).hourOfDay().roundFloorCopy());
 break;
case DAYS:

代码示例来源:origin: apache/drill

@Test
public void testTimeHoursMinutesSecondsFormat() {
 int hours = 11;
 int minutes = 50;
 String seconds = "05";
 DateTime date = parseDateFromPostgres(hours + ":" + minutes + ":" + seconds + " am", "hh12:mi:ss am");
 Assert.assertTrue(date.getHourOfDay() == hours &&
           date.getMinuteOfHour() == minutes &&
            date.getSecondOfMinute() == Integer.parseInt(seconds));
}

代码示例来源:origin: apache/drill

@Test
public void testTimeHours24MinutesSecondsFormat() {
 int hours = 15;
 int minutes = 50;
 int seconds = 5;
 DateTime date = parseDateFromPostgres(hours + ":" + minutes + ":" + seconds, "hh24:mi:ss");
 Assert.assertTrue(date.getHourOfDay() == hours &&
           date.getMinuteOfHour() == minutes &&
           date.getSecondOfMinute() == seconds);
}

代码示例来源:origin: prestodb/presto

assertFunction("extract(hour FROM " + TIMESTAMP_LITERAL + ")", BIGINT, (long) TIMESTAMP.getHourOfDay());
assertFunction("extract(day_of_week FROM " + TIMESTAMP_LITERAL + ")", BIGINT, (long) TIMESTAMP.getDayOfWeek());
assertFunction("extract(dow FROM " + TIMESTAMP_LITERAL + ")", BIGINT, (long) TIMESTAMP.getDayOfWeek());
assertFunction("extract(hour FROM " + WEIRD_TIMESTAMP_LITERAL + ")", BIGINT, (long) WEIRD_TIMESTAMP.getHourOfDay());
assertFunction("extract(day_of_week FROM " + WEIRD_TIMESTAMP_LITERAL + ")", BIGINT, (long) WEIRD_TIMESTAMP.getDayOfWeek());
assertFunction("extract(dow FROM " + WEIRD_TIMESTAMP_LITERAL + ")", BIGINT, (long) WEIRD_TIMESTAMP.getDayOfWeek());

代码示例来源:origin: linkedin/camus

public DateTime getCurrentHour() {
  DateTime time = new DateTime(zone);
  return new DateTime(time.getYear(), time.getMonthOfYear(), time.getDayOfMonth(), time.getHourOfDay(), 0, 0, 0, zone);
 }
}

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

new DateTime(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth(), now.getHourOfDay(), 30, 0, TZ);

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

DatePicker datePicker = (DatePicker) findViewById(R.id.inspected_at_date);
TimePicker timePicker = (TimePicker) findViewById(R.id.inspected_at_time);

DateTime inspected_at = DateTime.now()                // Typically pulled from DB.

int year    = inspected_at.getYear() ;
int month   = inspected_at.getMonthOfYear() - 1;      // Need to subtract 1 here.
int day     = inspected_at.getDayOfMonth();  
int hour    = inspected_at.getHourOfDay();
int minutes = inspected_at.getMinuteOfHour();

datePicker.updateDate(year, month, day);              // Set date.

timePicker.setCurrentHour(hour);                      // Set time.
timePicker.setCurrentMinute(minutes);

代码示例来源:origin: HubSpot/Singularity

public Date getNextValidTime() {
 final long now = System.currentTimeMillis();
 DateTime startDateTime = new DateTime(dtStart.getYear(), (dtStart.getMonthOfYear() - 1), dtStart.getDayOfMonth(),
  dtStart.getHourOfDay(), dtStart.getMinuteOfHour(), dtStart.getSecondOfMinute());
 RecurrenceRuleIterator timeIterator = recurrenceRule.iterator(startDateTime);
 int count = 0;
 while (timeIterator.hasNext() && (count < MAX_ITERATIONS || (recurrenceRule.hasPart(Part.COUNT) && count < recurrenceRule.getCount()))) {
  count ++;
  long nextRunAtTimestamp = timeIterator.nextMillis();
  if (nextRunAtTimestamp >= now) {
   return new Date(nextRunAtTimestamp);
  }
 }
 return null;
}

代码示例来源:origin: org.elasticsearch/elasticsearch

bucket.saveField(DateTimeFieldType.monthOfYear(), dt.getMonthOfYear());
bucket.saveField(DateTimeFieldType.dayOfMonth(), dt.getDayOfMonth());
bucket.saveField(DateTimeFieldType.hourOfDay(), dt.getHourOfDay());
bucket.saveField(DateTimeFieldType.minuteOfHour(), dt.getMinuteOfHour());
bucket.saveField(DateTimeFieldType.secondOfMinute(), dt.getSecondOfMinute());

代码示例来源:origin: org.jruby/jruby-complete

/**
 * @return hour-of-day (0..23)
 * @since 9.2
 */
public int getHour() { return dt.getHourOfDay(); }

代码示例来源:origin: metatron-app/metatron-discovery

private List<DateTime> getHourLabels(DateTime min, DateTime max, int unitSize) {
 List<DateTime> labels = new ArrayList<>();
 DateTime dt = new DateTime(min.getYear(), min.getMonthOfYear(), min.getDayOfMonth(),
               min.getHourOfDay() / unitSize * unitSize, 0);
 while (dt.isBefore(max) || dt.isEqual(max)) {
  labels.add(dt);
  dt = dt.plusHours(unitSize);
 }
 labels.add(dt);
 return labels;
}

代码示例来源:origin: metatron-app/metatron-discovery

private List<DateTime> getSecondLabels(DateTime min, DateTime max, int unitSize) {
 List<DateTime> labels = new ArrayList<>();
 DateTime dt = new DateTime(min.getYear(), min.getMonthOfYear(), min.getDayOfMonth(),
     min.getHourOfDay(), min.getMinuteOfHour(), min.getSecondOfMinute() / unitSize * unitSize);
 while (dt.isBefore(max) || dt.isEqual(max)) {
  labels.add(dt);
  dt = dt.plusSeconds(unitSize);
 }
 labels.add(dt);
 return labels;
}

代码示例来源:origin: metatron-app/metatron-discovery

private List<DateTime> getMillisLabels(DateTime min, DateTime max, int unitSize) {
 List<DateTime> labels = new ArrayList<>();
 DateTime dt = new DateTime(min.getYear(), min.getMonthOfYear(), min.getDayOfMonth(),
     min.getHourOfDay(), min.getMinuteOfHour(), min.getSecondOfMinute(), min.getMillisOfSecond() / unitSize * unitSize);
 while (dt.isBefore(max) || dt.isEqual(max)) {
  labels.add(dt);
  dt = dt.plusMillis(unitSize);
 }
 labels.add(dt);
 return labels;
}

代码示例来源:origin: org.jruby/jruby-complete

private static RubyDateTime calcAjdFromCivil(ThreadContext context, final DateTime dt, final int off,
                       final long subMillisNum, final long subMillisDen) {
  final Ruby runtime = context.runtime;
  long jd = civil_to_jd(dt.getYear(), dt.getMonthOfYear(), dt.getDayOfMonth(), ITALY);
  RubyNumeric fr = timeToDayFraction(context, dt.getHourOfDay(), dt.getMinuteOfHour(), dt.getSecondOfMinute());
  final RubyNumeric ajd = jd_to_ajd(context, jd, fr, off);
  RubyDateTime dateTime = new RubyDateTime(context, getDateTime(runtime), ajd, off, ITALY);
  dateTime.dt = dateTime.dt.withMillisOfSecond(dt.getMillisOfSecond());
  dateTime.subMillisNum = subMillisNum; dateTime.subMillisDen = subMillisDen;
  return dateTime;
}

相关文章

DateTime类方法