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

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

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

LocalDateTime.fromDateFields介绍

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

Each field is queried from the Date and assigned to the LocalDateTime. This is useful if you have been using the Date as a local date, 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 LocalDateTime with ISO chronology.
[中]使用完全相同的字段值从java.util.Date构造LocalDateTime。
从日期开始查询每个字段,并将其分配给LocalDateTime。如果您一直将该日期用作本地日期,而忽略区域,则此选项非常有用。
此方法的一个优点是,如果时区数据的版本在JDK和Joda时间之间不同,则此方法不受影响。这是因为本地字段值是使用JDK时区数据传输、计算的,而不使用Joda时区数据。
此工厂方法始终使用ISO编年史创建LocalDateTime。

代码示例

代码示例来源:origin: camunda/camunda-bpm-platform

getHourOfDay(), getMinuteOfHour(), getSecondOfMinute());
date.setTime(date.getTime() + getMillisOfSecond());
LocalDateTime check = LocalDateTime.fromDateFields(date);
if (check.isBefore(this)) {
    check = LocalDateTime.fromDateFields(date);
    check = LocalDateTime.fromDateFields(date);
  check = LocalDateTime.fromDateFields(earlier);
  if (check.equals(this)) {
    date = earlier;

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

@Override
  public LocalDateTime convert(Date in, Context context) throws Exception {
    if (in == null) return null;
    return LocalDateTime.fromDateFields(in);
  }
}

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

public static LocalDateTime sqlTimestampToJodaLocalDateTime(Timestamp timestamp) {
 return LocalDateTime.fromDateFields(timestamp);
}

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

@Nonnull
  @Override
  public LocalDateTime convert(java.time.Instant source) {
    return LocalDateTime.fromDateFields(new Date(source.toEpochMilli()));
  }
}

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

/**
 * Creates a new LocalDateTime-valued OData property with {@link EdmSimpleType#DATETIME}
 *
 * @param name  the property name
 * @param value  the property value
 * @return a new OData property instance
 */
public static OProperty<LocalDateTime> datetime(String name, Date value) {
 return new Impl<LocalDateTime>(name, EdmSimpleType.DATETIME, value != null ? LocalDateTime.fromDateFields(value) : null);
}

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

/**
 * Creates a new LocalDateTime-valued OData property with {@link EdmSimpleType#DATETIME}
 *
 * @param name  the property name
 * @param value  the property value
 * @return a new OData property instance
 */
public static OProperty<LocalDateTime> datetime(String name, Date value) {
 return new Impl<LocalDateTime>(name, EdmSimpleType.DATETIME, value != null ? LocalDateTime.fromDateFields(value) : null);
}

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

@Nonnull
  @Override
  public LocalDateTime convert(java.time.LocalDateTime source) {
    return LocalDateTime.fromDateFields(Jsr310Converters.LocalDateTimeToDateConverter.INSTANCE.convert(source));
  }
}

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

@Contract("null -> null; !null -> !null")
public static @Nullable LocalDateTime utilDateToJodaDateTime(final @Nullable Date d) {
  if (d == null) {
    return null;
  }
  return LocalDateTime.fromDateFields(d);
}

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

/**
 * Creates a new LocalDateTime-valued OData property with {@link EdmSimpleType#DATETIME}
 *
 * @param name  the property name
 * @param value  the property value
 * @return a new OData property instance
 */
public static OProperty<LocalDateTime> datetime(String name, Date value) {
 return new Impl<LocalDateTime>(name, EdmSimpleType.DATETIME, value != null ? LocalDateTime.fromDateFields(value) : null);
}

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

private FileInfo(File parent, File file) {
  this.isDir = file.isDirectory();
  this.context = null == parent ? "/" : parent.getAbsolutePath();
  this.path = printPath(file);
  this.size = printSize(file);
  this.timestamp = LocalDateTime.fromDateFields(new Date(file.lastModified()));
  this.hidden = file.isHidden();
}

代码示例来源:origin: com.stratio.mojo.unix/unix-sysv-pkg

public IEntry( Option<String> pkgClass, RelativePath path, File realPath )
{
  super( pkgClass, Option.<Boolean>none(),
      regularFile( path, fromDateFields( new Date( realPath.lastModified() ) ), realPath.length(),
            FileAttributes.EMPTY ) );
  this.realPath = realPath;
}

代码示例来源:origin: org.actframework/act

private FileInfo(File parent, File file) {
  this.isDir = file.isDirectory();
  this.context = null == parent ? "/" : parent.getAbsolutePath();
  this.path = printPath(file);
  this.size = printSize(file);
  this.timestamp = LocalDateTime.fromDateFields(new Date(file.lastModified()));
  this.hidden = file.isHidden();
}

代码示例来源:origin: tcplugins/tcWebHooks

private LocalDateTime findTimeStamp(WebHookExecutionStats webHookExecutionStats) {
  if (webHookExecutionStats.getRequestCompletedTimeStamp() != null) {
    return LocalDateTime.fromDateFields(webHookExecutionStats.getRequestCompletedTimeStamp());
  } else {
    return LocalDateTime.fromDateFields(webHookExecutionStats.getInitTimeStamp());
  }
}

代码示例来源:origin: no.arktekk.unix/unix-sysv-pkg

public IEntry( Option<String> pkgClass, RelativePath path, File realPath )
{
  super( pkgClass, Option.<Boolean>none(),
      regularFile( path, fromDateFields( new Date( realPath.lastModified() ) ), realPath.length(),
            Option.<FileAttributes>none() ) );
  this.realPath = realPath;
}

代码示例来源:origin: org.codehaus.mojo.unix/unix-pkg

public IEntry( Option<String> pkgClass, RelativePath path, File realPath )
{
  super( pkgClass, Option.<Boolean>none(),
      regularFile( path, fromDateFields( new Date( realPath.lastModified() ) ), realPath.length(),
            Option.<FileAttributes>none() ) );
  this.realPath = realPath;
}

代码示例来源:origin: com.stratio.mojo.unix/unix-rpm

public void beforeAssembly( Directory defaultDirectory )
{
  excludedSysPaths.add("/DEBIAN");
  excludedSysPaths.add("/DEBIAN/conffiles");
  Validate.validateNotNull( defaultDirectory );
  Directory root = UnixFsObject.directory( BASE, fromDateFields( new Date( 0 ) ), EMPTY );
  fileSystem = create( new PlainPackageFileSystemObject( root ),
             new PlainPackageFileSystemObject( defaultDirectory ) );
}

代码示例来源:origin: joda-time/joda-time-hibernate

public Object nullSafeGet(ResultSet resultSet, String string) throws SQLException {
  Object timestamp = StandardBasicTypes.TIMESTAMP.nullSafeGet(resultSet, string);
  if (timestamp == null) {
    return null;
  }
  if (timestamp instanceof Date) {
    return LocalDateTime.fromDateFields((Date) timestamp);
  } else if (timestamp instanceof Calendar) {
    return LocalDateTime.fromCalendarFields((Calendar) timestamp);
  }
  return new LocalDateTime(timestamp);
}

代码示例来源:origin: JodaOrg/joda-time-hibernate

public Object nullSafeGet(ResultSet resultSet, String string) throws SQLException {
  Object timestamp = StandardBasicTypes.TIMESTAMP.nullSafeGet(resultSet, string);
  if (timestamp == null) {
    return null;
  }
  if (timestamp instanceof Date) {
    return LocalDateTime.fromDateFields((Date) timestamp);
  } else if (timestamp instanceof Calendar) {
    return LocalDateTime.fromCalendarFields((Calendar) timestamp);
  }
  return new LocalDateTime(timestamp);
}

代码示例来源:origin: no.arktekk.unix/unix-rpm

public void beforeAssembly( Directory defaultDirectory )
{
  Validate.validateNotNull( defaultDirectory );
  Directory root = UnixFsObject.directory( BASE, fromDateFields( new Date( 0 ) ), EMPTY );
  fileSystem = create( new PlainPackageFileSystemObject( root ),
             new PlainPackageFileSystemObject( defaultDirectory ) );
}

代码示例来源:origin: org.codehaus.mojo.unix/unix-dpkg

private static List<UnixFsObject> process( InputStream is )
    throws IOException
  {
    TarInputStream tarInputStream = new TarInputStream( is );

    TarEntry entry = tarInputStream.getNextEntry();

    List<UnixFsObject> objects = new ArrayList<UnixFsObject>();

    while ( entry != null )
    {
      Option<UnixFileMode> mode = some( UnixFileMode.fromInt( entry.getMode() ) );
      FileAttributes attributes = new FileAttributes( some( entry.getUserName() ), some( entry.getGroupName() ), mode );
      RelativePath path = relativePath( entry.getName() );
      LocalDateTime lastModified = LocalDateTime.fromDateFields( entry.getModTime() );

      objects.add( entry.isDirectory() ?
        directory( path, lastModified, attributes ) :
        regularFile( path, lastModified, entry.getSize(), some( attributes ) ));

      entry = tarInputStream.getNextEntry();
    }

    return objects;
  }
}

相关文章