找到 34423 篇文章 相关编程

Java 中的 LocalTime plusMinutes() 方法

Samual Sam
更新于 2019-07-30 22:30:25

51 次浏览

可以使用 Java 中 LocalTime 类的 plusMinutes() 方法获取 LocalTime 对象的不可变副本,并在其中添加一些分钟。此方法需要一个参数,即要添加的分钟数,它返回添加了分钟数的 LocalTime 对象。以下给出一个演示此方法的程序示例:示例 实时演示import java.time.*; public class Demo {    public static void main(String[] args) {       LocalTime lt = LocalTime.now();       System.out.println("当前的 LocalTime 为: " + lt);       System.out.println("添加 15 分钟后的 LocalTime 为: ... 阅读更多

Java 中的 LocalTime toNanoOfDay() 方法

karthikeya Boyini
更新于 2019-07-30 22:30:25

50 次浏览

可以使用 Java 中 LocalTime 类的 toNanoOfDay() 方法获取一天中以纳秒表示的时间。此方法不需要参数,它返回一天中以纳秒表示的时间。以下给出一个演示此方法的程序示例:示例 实时演示import java.time.*; public class Main {    public static void main(String[] args) {       LocalTime lt = LocalTime.parse("05:15:30");       System.out.println("LocalTime 为: " + lt);       System.out.println("一天中的纳秒数为: " + lt.toNanoOfDay());    } }输出LocalTime 为: 05:15:30 一天中的纳秒数为: ... 阅读更多

Java 中的 LocalTime toSecondOfDay() 方法

Samual Sam
更新于 2019-07-30 22:30:25

45 次浏览

可以使用 Java 中 LocalTime 类的 toSecondOfDay() 方法获取一天中以秒表示的时间。此方法不需要参数,它返回一天中以秒表示的时间。以下给出一个演示此方法的程序示例:示例 实时演示import java.time.*; public class Main {    public static void main(String[] args) {       LocalTime lt = LocalTime.parse("05:15:30");       System.out.println("LocalTime 为: " + lt);       System.out.println("一天中的秒数为: " + lt.toSecondOfDay());    } }输出LocalTime 为: 05:15:30 一天中的秒数为: ... 阅读更多

Java 中的 LocalTime withSecond() 方法

karthikeya Boyini
更新于 2019-07-30 22:30:25

53 次浏览

可以使用 Java 中 LocalTime 类的 withSecond() 方法获取 LocalTime 的不可变副本,并根据需要更改秒数。此方法需要一个参数,即要设置为 LocalTime 的秒数,它返回根据需要更改了秒数的 LocalTime。以下给出一个演示此方法的程序示例:示例 实时演示import java.time.*; public class Main {    public static void main(String[] args) {       LocalTime lt1 = LocalTime.parse("23:15:30");       System.out.println("LocalTime 为: " + lt1);       LocalTime lt2 = lt1.withSecond(45);       ... 阅读更多

Java 中的 LocalTime withNano() 方法

Samual Sam
更新于 2019-07-30 22:30:25

57 次浏览

可以使用 Java 中 LocalTime 类的 withNano() 方法获取 LocalTime 的不可变副本,并根据需要更改纳秒数。此方法需要一个参数,即要设置为 LocalTime 的纳秒数,它返回根据需要更改了纳秒数的 LocalTime。以下给出一个演示此方法的程序示例:示例 实时演示import java.time.*; public class Main {    public static void main(String[] args) {       LocalTime lt1 = LocalTime.parse("23:15:30");       System.out.println("LocalTime 为: " + lt1);       LocalTime lt2 = lt1.withNano(5);       ... 阅读更多

Java 中的 LocalTime truncatedTo() 方法

karthikeya Boyini
更新于 2019-07-30 22:30:25

65 次浏览

可以使用 Java 中 LocalTime 的 truncatedTo() 方法获取不可变的截断 LocalTime 对象。此方法需要一个参数,即 LocalTime 对象截断到的 TemporalUnit,它返回不可变的截断对象。以下给出一个演示此方法的程序示例:示例 实时演示import java.time.*; import java.time.temporal.ChronoUnit; public class Demo {    public static void main(String[] args) {       LocalTime lt = LocalTime.parse("23:15:30");       System.out.println("LocalTime 为: " + lt.toString());       LocalTime truncatedLocalTime = lt.truncatedTo(ChronoUnit.MINUTES);       System.out.println("截断后的 LocalTime 为: " + truncatedLocalTime);    } }输出The ... 阅读更多

Java 中的 LocalTime toString() 方法

Samual Sam
更新于 2019-07-30 22:30:25

639 次浏览

可以使用 Java 中 LocalTime 类的 toString() 方法获取 LocalTime 对象的字符串值。此方法不需要参数,它返回 LocalTime 对象的字符串值。以下给出一个演示此方法的程序示例:示例 实时演示import java.time.*; public class Demo {    public static void main(String[] args) {       LocalTime lt = LocalTime.parse("23:15:30");       System.out.println("LocalTime 为: " + lt.toString());    } }输出LocalTime 为: 23:15:30现在让我们来理解上述程序。使用 toString() 方法获取 LocalTime 的字符串值,然后 ... 阅读更多

Java 中的 Instant minusSeconds() 方法

karthikeya Boyini
更新于 2019-07-30 22:30:25

155 次浏览

可以使用 Java 中 Instant 类的 minusSeconds() 方法获取 Instant 的不可变副本,并在其中减去一些秒数。此方法需要一个参数,即要减去的秒数,它返回减去了秒数的 Instant。以下给出一个演示此方法的程序示例:示例 实时演示import java.time.*; public class Demo {    public static void main(String[] args) {       Instant i = Instant.now();       System.out.println("当前的 Instant 为: " + i);       System.out.println("减去 10 秒后的 Instant 为: " + ... 阅读更多

Java 中的 Instant plusNanos() 方法

Samual Sam
更新于 2019-07-30 22:30:25

79 次浏览

可以使用 Java 中 Instant 类的 plusNanos() 方法获取 Instant 的不可变副本,并在其中添加一些纳秒数。此方法需要一个参数,即要添加的纳秒数,它返回添加了纳秒数的 Instant。以下给出一个演示此方法的程序示例:示例 实时演示import java.time.*; public class Demo {    public static void main(String[] args) {       Instant i = Instant.now();       System.out.println("当前的 Instant 为: " + i);       System.out.println("添加 1000000000 纳秒后的 Instant 为: " + ... 阅读更多

Java 中的 Instant plusSeconds() 方法

karthikeya Boyini
更新于 2019-07-30 22:30:25

452 次浏览

可以使用 Java 中 Instant 类的 plusSeconds() 方法获取 Instant 的不可变副本,并在其中添加一些秒数。此方法需要一个参数,即要添加的秒数,它返回添加了秒数的 Instant。以下给出一个演示此方法的程序示例:示例 实时演示import java.time.*; public class Demo {    public static void main(String[] args) {       Instant i = Instant.now();       System.out.println("当前的 Instant 为: " + i);       System.out.println("添加 10 秒后的 Instant 为: " + ... 阅读更多

广告

© . All rights reserved.