本文整理汇总了Java中java.time.LocalTime.getSecond方法的典型用法代码示例。如果您正苦于以下问题:Java LocalTime.getSecond方法的具体用法?Java LocalTime.getSecond怎么用?Java LocalTime.getSecond使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.LocalTime
的用法示例。
在下文中一共展示了LocalTime.getSecond方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: actionPerformed
import java.time.LocalTime; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
LocalTime localeTime = LocalTime.now();
int hour = localeTime.getHour();
int minute = localeTime.getMinute();
int second = localeTime.getSecond();
timeText.setText(String.format("%02d : %02d : %02d", hour, minute, second));
}
示例2: test_time_print
import java.time.LocalTime; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Test(dataProvider="time")
public void test_time_print(LocalTime time, FormatStyle timeStyle, int timeStyleOld, Locale locale) {
DateFormat old = DateFormat.getTimeInstance(timeStyleOld, locale);
Date oldDate = new Date(1970, 0, 0, time.getHour(), time.getMinute(), time.getSecond());
String text = old.format(oldDate);
DateTimeFormatter f = builder.appendLocalized(null, timeStyle).toFormatter(locale);
String formatted = f.format(time);
assertEquals(formatted, text);
}
示例3: test_time_parse
import java.time.LocalTime; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Test(dataProvider="time")
public void test_time_parse(LocalTime time, FormatStyle timeStyle, int timeStyleOld, Locale locale) {
DateFormat old = DateFormat.getTimeInstance(timeStyleOld, locale);
Date oldDate = new Date(1970, 0, 0, time.getHour(), time.getMinute(), time.getSecond());
String text = old.format(oldDate);
DateTimeFormatter f = builder.appendLocalized(null, timeStyle).toFormatter(locale);
TemporalAccessor parsed = f.parse(text, pos);
assertEquals(pos.getIndex(), text.length());
assertEquals(pos.getErrorIndex(), -1);
assertEquals(LocalTime.from(parsed), time);
}
示例4: isEqual
import java.time.LocalTime; //导入方法依赖的package包/类
private static boolean isEqual(LocalTime lt, java.sql.Time t) {
return lt.getHour() == t.getHours() &&
lt.getMinute() == t.getMinutes() &&
lt.getSecond() == t.getSeconds();
}
示例5: valueOf
import java.time.LocalTime; //导入方法依赖的package包/类
/**
* Obtains an instance of {@code Time} from a {@link LocalTime} object
* with the same hour, minute and second time value as the given
* {@code LocalTime}.
*
* @param time a {@code LocalTime} to convert
* @return a {@code Time} object
* @exception NullPointerException if {@code time} is null
* @since 1.8
*/
@SuppressWarnings("deprecation")
public static Time valueOf(LocalTime time) {
return new Time(time.getHour(), time.getMinute(), time.getSecond());
}
示例6: valueOf
import java.time.LocalTime; //导入方法依赖的package包/类
/**
* Obtains an instance of {@code Time} from a {@link LocalTime} object
* with the same hour, minute and second time value as the given
* {@code LocalTime}. The nanosecond field from {@code LocalTime} is
* not part of the newly created {@code Time} object.
*
* @param time a {@code LocalTime} to convert
* @return a {@code Time} object
* @exception NullPointerException if {@code time} is null
* @since 1.8
*/
@SuppressWarnings("deprecation")
public static Time valueOf(LocalTime time) {
return new Time(time.getHour(), time.getMinute(), time.getSecond());
}