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

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

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

LocalTime.fromDateFields介绍

[英]Constructs a LocalTime from a java.util.Date using exactly the same field values.

Each field is queried from the Date and assigned to the LocalTime. This is useful if you have been using the Date as a local time, ignoring the zone.

One advantage of this method is that this method is unaffected if the version of the time zone data differs between the JDK and Joda-Time. That is because the local field values are transferred, calculated using the JDK time zone data and without using the Joda-Time time zone data.

This factory method always creates a LocalTime with ISO chronology.
[中]使用完全相同的字段值从java.util.Date构造LocalTime。
从日期开始查询每个字段,并将其分配给LocalTime。如果您一直将日期用作本地时间,而忽略区域,则此选项非常有用。
此方法的一个优点是,如果时区数据的版本在JDK和Joda时间之间不同,则此方法不受影响。这是因为本地字段值是使用JDK时区数据传输、计算的,而不使用Joda时区数据。
此工厂方法始终使用ISO时间顺序创建LocalTime。

代码示例

代码示例来源:origin: arnaudroger/SimpleFlatMapper

  1. @Override
  2. public LocalTime convert(Date in, Context context) throws Exception {
  3. if (in == null) return null;
  4. return LocalTime.fromDateFields(in);
  5. }
  6. }

代码示例来源:origin: net.s-jr.utils.converterutils/joda-converter-utils

  1. @Contract("null -> null; !null -> !null")
  2. public static @Nullable LocalTime utilDateToJodaTime(final @Nullable Date d) {
  3. if (d == null) {
  4. return null;
  5. }
  6. return LocalTime.fromDateFields(d);
  7. }

代码示例来源:origin: org.jboss.oreva/odata-core

  1. /**
  2. * Creates a new LocalTime-valued OData property with {@link EdmSimpleType#TIME}
  3. *
  4. * @param name the property name
  5. * @param value the property value
  6. * @return a new OData property instance
  7. */
  8. public static OProperty<LocalTime> time(String name, Date value) {
  9. return new Impl<LocalTime>(name, EdmSimpleType.TIME, value != null ? LocalTime.fromDateFields(value) : null);
  10. }

代码示例来源:origin: org.sonatype.sisu/sisu-odata4j

  1. /**
  2. * Creates a new LocalTime-valued OData property with {@link EdmSimpleType#TIME}
  3. *
  4. * @param name the property name
  5. * @param value the property value
  6. * @return a new OData property instance
  7. */
  8. public static OProperty<LocalTime> time(String name, Date value) {
  9. return new Impl<LocalTime>(name, EdmSimpleType.TIME, value != null ? LocalTime.fromDateFields(value) : null);
  10. }

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

  1. /**
  2. * Creates a new LocalTime-valued OData property with {@link EdmSimpleType#TIME}
  3. *
  4. * @param name the property name
  5. * @param value the property value
  6. * @return a new OData property instance
  7. */
  8. public static OProperty<LocalTime> time(String name, Date value) {
  9. return new Impl<LocalTime>(name, EdmSimpleType.TIME, value != null ? LocalTime.fromDateFields(value) : null);
  10. }

代码示例来源:origin: org.kuali.kpme/kpme-tk-lm-impl

  1. public String getActionTime() {
  2. return actionDateTime != null ? FORMATTER.print(LocalTime.fromDateFields(actionDateTime)) : getLocalTimeString();
  3. }

代码示例来源:origin: org.sonatype.sisu/sisu-odata4j

  1. return (T) new LocalTime(obj);
  2. else if (Date.class.isAssignableFrom(objClass) && !objClass.equals(java.sql.Date.class))
  3. return (T) LocalTime.fromDateFields((Date) obj);
  4. else if (Calendar.class.isAssignableFrom(objClass))
  5. return (T) LocalTime.fromCalendarFields((Calendar) obj);

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

  1. return (T) new LocalTime(obj);
  2. else if (Date.class.isAssignableFrom(objClass) && !objClass.equals(java.sql.Date.class))
  3. return (T) LocalTime.fromDateFields((Date) obj);
  4. else if (Calendar.class.isAssignableFrom(objClass))
  5. return (T) LocalTime.fromCalendarFields((Calendar) obj);

代码示例来源:origin: org.jboss.oreva/odata-core

  1. return (T) new LocalTime(obj);
  2. else if (Date.class.isAssignableFrom(objClass) && !objClass.equals(java.sql.Date.class))
  3. return (T) LocalTime.fromDateFields((Date) obj);
  4. else if (Calendar.class.isAssignableFrom(objClass))
  5. return (T) LocalTime.fromCalendarFields((Calendar) obj);

代码示例来源:origin: org.kuali.kpme/kpme-tk-lm-impl

  1. protected List<Shift> createShifts(ShiftDifferentialRule rule, LocalDateTime spanBegin, LocalDateTime spanEnd, DateTimeZone zone) {
  2. DateTime spanBeginDT = spanBegin.toDateTime(zone);
  3. DateTime spanEndDT = spanEnd.toDateTime(zone);
  4. Interval calendarEntryInterval = new Interval(spanBeginDT, spanEndDT);
  5. DateTime shiftEnd = LocalTime.fromDateFields(rule.getEndTime()).toDateTime(spanBeginDT).minusDays(1);
  6. DateTime shiftStart = LocalTime.fromDateFields(rule.getBeginTime()).toDateTime(spanBeginDT).minusDays(1);
  7. if (shiftEnd.isBefore(shiftStart) || shiftEnd.isEqual(shiftStart)) {
  8. shiftEnd = shiftEnd.plusDays(1);
  9. }
  10. List<Shift> shifts = new ArrayList<Shift>();
  11. Interval shiftInterval = new Interval(shiftStart, shiftEnd);
  12. //possible that there is no overlap between 1st interval and cal entry interval... if so, add a day.
  13. if (!calendarEntryInterval.overlaps(shiftInterval)) {
  14. shiftInterval = incrementShift(shiftInterval);
  15. }
  16. while (calendarEntryInterval.overlaps(shiftInterval)) {
  17. if (ruleIsActiveForDay(shiftInterval.getStart(), rule)) {
  18. shifts.add(new Shift(rule, shiftInterval, zone));
  19. }
  20. shiftInterval = incrementShift(shiftInterval);
  21. }
  22. return shifts;
  23. }

相关文章