Data Structure
 Networking
 RDBMS
 Operating System
 Java
 MS Excel
 iOS
 HTML
 CSS
 Android
 Python
 C Programming
 C++
 C#
 MongoDB
 MySQL
 Javascript
 PHP
- Selected Reading
 - UPSC IAS Exams Notes
 - Developer's Best Practices
 - Questions and Answers
 - Effective Resume Writing
 - HR Interview Questions
 - Computer Glossary
 - Who is Who
 
Programming Articles - Page 2762 of 3366
 
			
			81 Views
The time in the form of nanoseconds of the day can be obtained using the toNanoOfDay() method in the LocalTime class in Java. This method requires no parameters and it returns the time in the form of nanoseconds of the day.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Main { public static void main(String[] args) { LocalTime lt = LocalTime.parse("05:15:30"); System.out.println("The LocalTime is: " + lt); System.out.println("The nanoseconds of the day are: " + lt.toNanoOfDay()); } }OutputThe LocalTime is: 05:15:30 The nanoseconds of ... Read More
 
			
			93 Views
The time in the form of seconds of the day can be obtained using the toSecondOfDay() method in the LocalTime class in Java. This method requires no parameters and it returns the time in the form of seconds of the day.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Main { public static void main(String[] args) { LocalTime lt = LocalTime.parse("05:15:30"); System.out.println("The LocalTime is: " + lt); System.out.println("The seconds of the day are: " + lt.toSecondOfDay()); } }OutputThe LocalTime is: 05:15:30 The seconds of ... Read More
 
			
			78 Views
An immutable copy of a LocalTime with the seconds altered as required is done using the method withSecond() in the LocalTime class in Java. This method requires a single parameter i.e. the second that is to be set in the LocalTime and it returns the LocalTime with the second altered as required.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Main { public static void main(String[] args) { LocalTime lt1 = LocalTime.parse("23:15:30"); System.out.println("The LocalTime is: " + lt1); LocalTime lt2 = lt1.withSecond(45); ... Read More
 
			
			83 Views
An immutable copy of a LocalTime with the nanoseconds altered as required is done using the method withNano() in the LocalTime class in Java. This method requires a single parameter i.e. the nanosecond that is to be set in the LocalTime and it returns the LocalTime with the nanosecond altered as required.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Main { public static void main(String[] args) { LocalTime lt1 = LocalTime.parse("23:15:30"); System.out.println("The LocalTime is: " + lt1); LocalTime lt2 = lt1.withNano(5); ... Read More
 
			
			106 Views
An immutable truncated LocalTime object can be obtained using the truncatedTo() method in the LocalTime in Java. This method requires a single parameter i.e. the TemporalUnit till which the LocalTime object is truncated and it returns the immutable truncated object.A program that demonstrates this is given as follows −Example Live Demoimport 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("The LocalTime is: " + lt.toString()); LocalTime truncatedLocalTime = lt.truncatedTo(ChronoUnit.MINUTES); System.out.println("The truncated LocalTime is: " + truncatedLocalTime); } }OutputThe ... Read More
 
			
			883 Views
The string value of the LocalTime object can be obtained using the method toString() in the LocalTime class in Java. This method requires no parameters and it returns the string value of the LocalTime object.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo { public static void main(String[] args) { LocalTime lt = LocalTime.parse("23:15:30"); System.out.println("The LocalTime is: " + lt.toString()); } }OutputThe LocalTime is: 23:15:30Now let us understand the above program.The string value of the LocalTime is obtained using the method toString() and then this value ... Read More
 
			
			201 Views
An immutable copy of a instant where some seconds are subtracted from it can be obtained using the minusSeconds() method in the Instant class in Java. This method requires a single parameter i.e. the number of seconds to be subtracted and it returns the instant with the subtracted seconds.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo { public static void main(String[] args) { Instant i = Instant.now(); System.out.println("The current instant is: " + i); System.out.println("An instant with 10 seconds subtracted is: " + ... Read More
 
			
			119 Views
An immutable copy of a instant where some nanoseconds are added to it can be obtained using the plusNanos() method in the Instant class in Java. This method requires a single parameter i.e. the number of nanoseconds to be added and it returns the instant with the added nanoseconds.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo { public static void main(String[] args) { Instant i = Instant.now(); System.out.println("The current instant is: " + i); System.out.println("An instant with 1000000000 nanoseconds added is: " + ... Read More
 
			
			602 Views
An immutable copy of a instant where some seconds are added to it can be obtained using the plusSeconds() method in the Instant class in Java. This method requires a single parameter i.e. the number of seconds to be added and it returns the instant with the added seconds.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo { public static void main(String[] args) { Instant i = Instant.now(); System.out.println("The current instant is: " + i); System.out.println("An instant with 10 seconds added is: " + ... Read More
 
			
			226 Views
An immutable copy of a instant where some milliseconds are added to it can be obtained using the plusMillis() method in the Instant class in Java. This method requires a single parameter i.e. the number of milliseconds to be added and it returns the instant with the added milliseconds.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo { public static void main(String[] args) { Instant i = Instant.now(); System.out.println("The current instant is: " + i); System.out.println("An instant with 60000 milliseconds added is: " + ... Read More