Maruthi Krishna has Published 951 Articles

How to use Clock in Java 8?

Maruthi Krishna

Maruthi Krishna

Updated on 07-Aug-2019 11:18:30

179 Views

The java.time package of Java provides API’s for dates, times, instances and durations. It provides various classes like Clock, LocalDate, LocalDateTime, LocalTime, MonthDay, Year, YearMonth etc. Using classes of this package you can get details related to date and time in much simpler way compared to previous alternatives.The Clock class ... Read More

How to find Date after 1 week in java 8?

Maruthi Krishna

Maruthi Krishna

Updated on 07-Aug-2019 11:16:58

1K+ Views

The java.time package of Java provides API’s for dates, times, instances and durations. It provides various classes like Clock, LocalDate, LocalDateTime, LocalTime, MonthDay, Year, YearMonth etc. Using classes of this package you can get details related to date and time in much simpler way compared to previous alternatives.Java.time.LocalDate − This ... Read More

How to get current Time in Java 8?

Maruthi Krishna

Maruthi Krishna

Updated on 07-Aug-2019 11:16:22

7K+ Views

From Java8 java.time package was introduced. This provides classes like LocalDate, LocalTime, LocalDateTime, MonthDay etc. Using classes of this package you can get time and date in a simpler way.Java.time.LocalTime − This class represents a time object without time zone in ISO-8601 calendar system. The now() method of this class ... Read More

How to check if two dates are equal in Java 8?

Maruthi Krishna

Maruthi Krishna

Updated on 07-Aug-2019 11:10:02

1K+ Views

The java.time package of Java provides API’s for dates, times, instances and durations. It provides various classes like Clock, LocalDate, LocalDateTime, LocalTime, MonthDay, Year, YearMonth etc. Using classes of this package you can get details related to date and time in much simpler way compared to previous alternatives.Java.time.LocalDate − This ... Read More

How to get a particular date in Java 8?

Maruthi Krishna

Maruthi Krishna

Updated on 07-Aug-2019 11:06:02

853 Views

The java.time package of Java provides API’s for dates, times, instances and durations. It provides various classes like Clock, LocalDate, LocalDateTime, LocalTime, MonthDay, Year, YearMonth, etc. Using classes of this package you can get details related to date and time in much simpler way compared to previous alternatives.Java.time.LocalDate − This ... Read More

How to get current day, month and year in Java 8?

Maruthi Krishna

Maruthi Krishna

Updated on 07-Aug-2019 11:02:18

22K+ Views

The java.time package of Java provides API’s for dates, times, instances and durations. It provides various classes like Clock, LocalDate, LocalDateTime, LocalTime, MonthDay, Year, YearMonth etc. Using classes of this package you can get details related to date and time in much simpler way compared to previous alternatives.Java.time.LocalDate − This ... Read More

How to get today's date in Java8?

Maruthi Krishna

Maruthi Krishna

Updated on 07-Aug-2019 11:00:41

3K+ Views

Prior to Java8 to get current date and time we use to rely on various classes like SimpleDateFormat, Calendar etc.Exampleimport java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class LocalDateJava8 {    public static void main(String args[]) {       Date date = new Date();       String timeFormatString = ... Read More

If a method in parent class “throws Exception”, can we remove it in overridden method in java?

Maruthi Krishna

Maruthi Krishna

Updated on 07-Aug-2019 10:49:56

1K+ Views

While a superclass method throws an exception while overriding it you need to follow the certain rules.The sub class method Should throw Same exception or, sub type −It should not throw an exception of super type −You may leave the method in sub class Without throwing any exceptionAccording to the ... Read More

What is InputMisMatchException in Java how do we handle it?

Maruthi Krishna

Maruthi Krishna

Updated on 07-Aug-2019 10:47:22

4K+ Views

From Java 1.5 Scanner class was introduced. This class accepts a File, InputStream, Path and, String objects, reads all the primitive data types and Strings (from the given source) token by token using regular expressions.To read various datatypes from the source using the nextXXX() methods provided by this class namely, ... Read More

What changes has been introduced in JDK7 related to Exception handling in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 07-Aug-2019 09:17:57

59 Views

Since Java 7 try-with resources was introduced. In this we declare one or more resources in the try block and these will be closed automatically after the use. (at the end of the try block)The resources we declare in the try block should extend the java.lang.AutoCloseable class.ExampleFollowing program demonstrates the ... Read More

Advertisements