本文整理汇总了Java中java.time.LocalDateTime.getSecond方法的典型用法代码示例。如果您正苦于以下问题:Java LocalDateTime.getSecond方法的具体用法?Java LocalDateTime.getSecond怎么用?Java LocalDateTime.getSecond使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.LocalDateTime
的用法示例。
在下文中一共展示了LocalDateTime.getSecond方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: javaToDosTime
import java.time.LocalDateTime; //导入方法依赖的package包/类
/**
* Converts Java time to DOS time.
*/
private static long javaToDosTime(long time) {
Instant instant = Instant.ofEpochMilli(time);
LocalDateTime ldt = LocalDateTime.ofInstant(
instant, ZoneId.systemDefault());
int year = ldt.getYear() - 1980;
if (year < 0) {
return (1 << 21) | (1 << 16);
}
return (year << 25 |
ldt.getMonthValue() << 21 |
ldt.getDayOfMonth() << 16 |
ldt.getHour() << 11 |
ldt.getMinute() << 5 |
ldt.getSecond() >> 1) & 0xffffffffL;
}
示例2: convertToPresentation
import java.time.LocalDateTime; //导入方法依赖的package包/类
@Override
public String convertToPresentation(LocalDateTime value, Class<? extends String> targetType, Locale locale)
throws ConversionException {
if (value==null){
return null;
}
if (value.getHour()==0 && value.getMinute()==0 && value.getSecond()==0){
return formatterDate.format(value);
}
return formatterDateTime.format(value);
}
示例3: dateFormatterForLogs
import java.time.LocalDateTime; //导入方法依赖的package包/类
private static String dateFormatterForLogs(LocalDateTime dateTime) {
String dateString = "[";
dateString += dateTime.getDayOfMonth() + "_";
dateString += dateTime.getMonthValue() + "_";
dateString += dateTime.getYear() + "_";
dateString += dateTime.getHour() + ":";
dateString += dateTime.getMinute() + ":";
dateString += dateTime.getSecond();
dateString += "] ";
return dateString;
}
示例4: javaToDosTime
import java.time.LocalDateTime; //导入方法依赖的package包/类
public static long javaToDosTime(long time) {
Instant instant = Instant.ofEpochMilli(time);
LocalDateTime ldt = LocalDateTime.ofInstant(
instant, ZoneId.systemDefault());
int year = ldt.getYear() - 1980;
if (year < 0) {
return (1 << 21) | (1 << 16);
}
return (year << 25 |
ldt.getMonthValue() << 21 |
ldt.getDayOfMonth() << 16 |
ldt.getHour() << 11 |
ldt.getMinute() << 5 |
ldt.getSecond() >> 1) & 0xffffffffL;
}
示例5: DateTimeParameterObject
import java.time.LocalDateTime; //导入方法依赖的package包/类
DateTimeParameterObject(final LocalDateTime localDateTime, @Nullable final String pattern) {
this.localDateTime = localDateTime;
this.pattern = Optional.ofNullable(pattern);
this.dayOfMonth = localDateTime.getDayOfMonth();
this.month = localDateTime.getMonthValue();
this.year = localDateTime.getYear();
this.hour = localDateTime.getHour();
this.minute = localDateTime.getMinute();
this.second = localDateTime.getSecond();
this.instant = localDateTime.atZone(ZoneId.systemDefault()).toEpochSecond();
}
示例6: valueOf
import java.time.LocalDateTime; //导入方法依赖的package包/类
/**
* Obtains an instance of {@code Timestamp} from a {@code LocalDateTime}
* object, with the same year, month, day of month, hours, minutes,
* seconds and nanos date-time value as the provided {@code LocalDateTime}.
* <p>
* The provided {@code LocalDateTime} is interpreted as the local
* date-time in the local time zone.
*
* @param dateTime a {@code LocalDateTime} to convert
* @return a {@code Timestamp} object
* @exception NullPointerException if {@code dateTime} is null.
* @since 1.8
*/
@SuppressWarnings("deprecation")
public static Timestamp valueOf(LocalDateTime dateTime) {
return new Timestamp(dateTime.getYear() - 1900,
dateTime.getMonthValue() - 1,
dateTime.getDayOfMonth(),
dateTime.getHour(),
dateTime.getMinute(),
dateTime.getSecond(),
dateTime.getNano());
}