• 26 November

    Check if Date Is Between Two Dates in Java

    Introduction In this article, we will discuss and dwell on how to compare dates in Java. The problem statement is : Check if a Date is between two dates in Java. This roughly translates to Given a date, we need to check if it lies between the range of two dates. Let us understand this […]

  • 05 October

    Find Difference Between Two Instant in Java

    In this post, we will see how to find difference between two Instant in Java. Ways to find difference between two Instant in Java There are multiple ways to find difference between two Instant in various time units such as Days, Hours, Minutes, Seconds etc. Using Instant’s until() method To find difference between two Instant, […]

  • 05 October

    Find Difference Between Two LocalDate in Java

    In this post, we will see how to find difference between two LocalDate in Java. Ways to find difference between two LocalDate in Java There are multiple ways to find difference between two LocalDate in various time units such as Days, Months, Years etc. Using LocalDate’s until() method We can use LocalDate’s until() method to […]

  • 26 September

    Get List of Weekday Names in Java

    In this post, we will see how to get list of weekday names in Java. Using DateFormatSymbols’s getWeekdays() method We can use DateFormatSymbols's getWeekdays() to get list of weekday names in Java. It will provide complete weekday names like Sunday, Monday etc. [crayon-6623051dc5e6d860803042/] Output [crayon-6623051dc5e77148955465/] Using DateFormatSymbols’s getShortWeekdays() method [For short names] If you need […]

  • 24 September

    Get List of Month Names in Java

    In this post, we will see how to get list of months name in Java. Using DateFormatSymbols’s getMonth() method We can use DateFormatSymbols's getMonth() to get list of months in Java. It will provide complete month names like January, February etc. [crayon-6623051dc6742134469839/] Output [crayon-6623051dc674d003073094/] Using DateFormatSymbols’s getShortMonths() method [ For short names] If you need […]

  • 20 September

    Get Unix Timestamp in Java

    In this post, we will get unix timestamp in Java. As per wikipedia Unix time is a system for describing a point in time. It is the number of seconds that have elapsed since the Unix epoch, excluding leap seconds. The Unix epoch is 00:00:00 UTC on 1 January 1970. Unix time is standard way […]

  • 17 September

    Check if Date Is Weekend or Weekday in Java

    In this post, we will see how to check if Date is weekend or weekday in Java. Please note that we will consider Saturaday/Sunday as weekend and rest five days of week as weekdays. Using LocalDate’s getDayOfWeek() method We can use LocalDate’s getDayOfWeek() method to check if given date is weekend or weekday in Java. […]

  • 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() […]

  • 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 […]