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

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

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

DateTime.toLocalTime介绍

[英]Converts this object to a LocalTime with the same time and chronology.
[中]将此对象转换为具有相同时间和年表的LocalTime

代码示例

代码示例来源:origin: spring-projects/spring-framework

@Override
  public LocalTime convert(DateTime source) {
    return source.toLocalTime();
  }
}

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

@Override
  public LocalTime convert(DateTime source) {
    return source.toLocalTime();
  }
}

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

protected LocalTime computeReferenceTime(@Nullable final DateTime referenceTime) {
  return referenceTime == null ? null : ClockUtil.toDateTime(referenceTime, getFixedOffsetTimeZone()).toLocalTime();
}

代码示例来源:origin: apache/servicemix-bundles

@Override
  public LocalTime convert(DateTime source) {
    return source.toLocalTime();
  }
}

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

DateTimeZone zone = DateTimeZone.forID ( "America/Denver" );
DateTime dateTime = new DateTime ( zone );
String output = dateTime.toLocalTime ().toString ();

代码示例来源:origin: com.mysema.converters/converters

@Override
public LocalTime fromString(String str) {
  return fromStringFmt.parseDateTime(str).toLocalTime();
}

代码示例来源:origin: org.jadira.usertype/usertype.core

@Override
public LocalTime fromNonNullValue(Time value) {
  DateTime dateTime = new DateTime(value.getTime());
  LocalTime localTime = dateTime.toLocalTime();
  return localTime;
}

代码示例来源:origin: seemoo-lab/fitness-app

public static LocalTime getValidTimeOrNull(String date) {
    if (StringUtils.isEmpty(date)) return null;

    try {
      return FitbitApiService.LOCAL_TIME_HOURS_MINUTES_FORMATTER.parseDateTime(date).toLocalTime();
    } catch (Exception e) {
      log.error(e);
    }

    return null;
  }
}

代码示例来源:origin: com.github.workerframework/worker-testing-integration

private void logWithTimestamp(final String debugInfo)
  {
    System.out.println(DateTime.now().toLocalTime().toString() + debugInfo);
  }
}

代码示例来源:origin: com.ning.billing/killbill-util

public DateAndTimeZoneContext(final DateTime effectiveDateTime, final DateTimeZone accountTimeZone, final Clock clock) {
  this.clock = clock;
  this.referenceTime = effectiveDateTime != null ? effectiveDateTime.toLocalTime() : null;
  this.accountTimeZone = accountTimeZone;
  this.offsetFromUtc = computeOffsetFromUtc(effectiveDateTime, accountTimeZone);
}

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

DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
DateTime today = new DateTime();
DateTime start = formatter.parseDateTime(dtStart);
if (today.toLocalDate().compareTo(start.toLocalDate()) != 0) {
  System.out.println("true");
} else {
  System.out.println("false");
}

if (today.toLocalTime().compareTo(start.toLocalTime()) > 0) {
...
}

代码示例来源:origin: com.github.workerframework/worker-testing-integration

private void logWithTimestamp(final String debugInfo)
  {
    System.out.println(DateTime.now().toLocalTime().toString() + debugInfo);
  }
}

代码示例来源:origin: ZieIony/NaturalDateFormat

private void formatSeconds(DateTime now, DateTime then, StringBuilder text) {
  int secondsBetween = Seconds.secondsBetween(now.toLocalTime(), then.toLocalTime()).getSeconds();
  if (secondsBetween == 0) {
    text.append(context.getString(R.string.now));
  } else if (secondsBetween > 0) {    // in N seconds
    text.append(context.getResources().getQuantityString(R.plurals.carbon_inSeconds, secondsBetween, secondsBetween));
  } else {    // N seconds ago
    text.append(context.getResources().getQuantityString(R.plurals.carbon_secondsAgo, -secondsBetween, -secondsBetween));
  }
}

代码示例来源:origin: org.jasig.portlet.utils/portlet-ws-util

public static LocalTime parseTime(String lexicalXSDTime) {
    final Calendar cal = DatatypeConverter.parseTime(lexicalXSDTime);
    return new DateTime(cal).withZone(DateTimeZone.UTC).toLocalTime();
  }
}

代码示例来源:origin: com.github.cafdataprocessing/corepolicy-condition-engine

private BiFunction<DateTime, DateOperator, Boolean> getTwoTimesComparer(LocalTime targetDate) {
  return (DateTime date, DateOperator dateOperator) -> {
    if (targetDate == null || date == null) {
      return false;
    }
    int result = date.toLocalTime().compareTo(targetDate);
    return resultMatchesOperator(result, dateOperator);
  };
}

代码示例来源:origin: caelum/vraptor

public LocalTime convert(String value, Class<? extends LocalTime> type, ResourceBundle bundle) {
    try {
      DateTime out = new LocaleBasedJodaTimeConverter(localization).convert(value, shortTime());
      if (out == null) {
      return null;
      }
      
      return out.toLocalTime();
    } catch (Exception e) {
        throw new ConversionError(MessageFormat.format(bundle.getString("is_not_a_valid_time"), value));
    } 
  }
}

代码示例来源:origin: org.jadira.usertype/usertype.core

@Override
public TimeOfDay fromNonNullValue(Time value) {
  DateTime dateTime = new DateTime(value.getTime());
  LocalTime localTime = dateTime.toLocalTime();
  final TimeOfDay timeOfDay = new TimeOfDay(localTime.getHourOfDay(), localTime.getMinuteOfHour(), localTime.getSecondOfMinute(), localTime.getMillisOfSecond(), localTime.getChronology());
  return timeOfDay;
}

代码示例来源:origin: org.jadira.usertype/usertype.jodatime

@Override
public TimeOfDay fromNonNullValue(Timestamp value) {
  final LocalTime localTime = Formatter.LOCAL_DATETIME_PARSER.parseDateTime(value.toString()).toLocalTime();
  final TimeOfDay timeOfDay = new TimeOfDay(localTime.getHourOfDay(), localTime.getMinuteOfHour(), localTime.getSecondOfMinute(), localTime.getMillisOfSecond(), localTime.getChronology());
  return timeOfDay;
}

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

LocalTime userTime = ...; // Parse the user input
DateTime now = DateTime().now();
LocalDate today = now.toLocalDate();
LocalDate resultDate = now.toLocalTime().isBefore(userTime) ? today : today.plusDays(1);
DateTime result = resultDate.toDateTime(userTime, now.getTimeZone());

代码示例来源:origin: org.motechproject/motech-pillreminder-api

@JsonIgnore
public boolean isTodaysDosageResponseCaptured() {
  LocalDate today = DateUtil.today();
  LocalDate yesterday = today.minusDays(1);
  LocalTime localNow = DateUtil.now().toLocalTime();
  if (responseLastCapturedDate == null) {
    return false;
  }
  if (responseLastCapturedDate.equals(today)) {
    return true;
  }
  return responseLastCapturedDate.equals(yesterday) && new Time(localNow.getHourOfDay(), localNow.getMinuteOfHour()).isBefore(dosageTime);
}

相关文章

DateTime类方法