当前位置: 首页>>代码示例>>Java>>正文


Java LocalDateTime.getSecond方法代码示例

本文整理汇总了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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:ZipUtils.java

示例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);
}
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:12,代码来源:GridConverter.java

示例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;
}
 
开发者ID:samurayrj,项目名称:rubenlagus-TelegramBots,代码行数:12,代码来源:FileFormatter.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:ZipUtils.java

示例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();
}
 
开发者ID:rooting-company,项目名称:roxana,代码行数:12,代码来源:DateTimeParameterObject.java

示例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());
}
 
开发者ID:madHEYsia,项目名称:ClassroomFlipkart,代码行数:24,代码来源:Timestamp.java


注:本文中的java.time.LocalDateTime.getSecond方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。