• 07 February

    Get number of days in Month in java

    Learn about how to get number of days in Month in java. Get number of days in Month in java Using YearMonth’s lengthOfMonth() [Java 8] You can use YearMonth‘s lengthOfMonth() method to get number of days in Month in java. Pass Year and month to YearMonth’s of and create YearMonth object. Call lengthOfMonth() on YearMonth’s […]

  • Get last day of month in java
    04 February

    Get last day of Month in java

    Learn about how to get last day of month in java. There are times when you need to get last day of month to process data at the end of each month. For example: Processing salaries of the employee in your company. There are multiple ways to get last day of month in java Ways […]

  • 25 May

    Format Date to yyyy-MM-dd in java

    In this post, we will see how to Format Date to yyyy-MM-dd in java. There are multiple ways to format Date to yyyy-MM-dd in java. Let’s go through them. Using DateTimeFormatter with LocalDate (Java 8) To Format Date to yyyy-MM-dd in java: Create a LocalDateTime object. Use DateTimeFormatter.ofPattern() to specify the pattern yyyy-MM-dd Call format() […]

  • Convert Date to LocalDate in java
    12 January

    Java Date to LocalDate

    In this post, we will see how to convert Date to LocalDate in java. Sometimes, we may need to convert Date to new Java 8 APIs and vice versa. There are multiple ways to convert Date to LocalDate in java. Read also: Convert LocalDate to Date in java Using toInstant() method of Date class You […]

  • Convert LocalDate to Date in java
    11 January

    Java LocalDate to Date

    In this post, we will see how to convert LocalDate to Date. Java 8 has introduced a lot of new APIs for Date and time. There can be many ways to convert Java LocalDateTime to date. Using Instant object You can convert LocalDate to Date using Instant object which we can from Zone. Here is […]

  • 30 December

    How to get day name from date in java

    Learn about how to get day name of week from date in java

  • 22 December

    How to add days to date in java

    Learn about how to add days to Date using Calendar and LocalDate in java.

  • 23 March

    Get current timestamp in java

    In this post, we will see how to get current timestamp in java. There are multiple ways to get current timestamp in java. Using Java 8’s Instant class There are three ways to get timestamp using Java 8‘s java.time.Instant class. Using Instant.now() [crayon-632250ed1a986322134977/] Using date.toInstant() [crayon-632250ed1a98f824037991/] Using timestamp.toInstant() [crayon-632250ed1a991298951388/] Here is complete example for get […]

  • 22 April

    How to calculate difference between two dates in java

    In this post, we will see how to calculate difference between two dates. Sometimes we have requirement to find no. of days between two dates or no. of hours between two dates. Java Program: [crayon-632250ed1b1e5009208493/] When you run above program, you will get following output: [crayon-632250ed1b1ee088929199/]