Core java
05 OctoberFind 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 OctoberFind Difference Between Two LocalDateTime in Java
In this post, we will see how to find difference between two LocalDateTime in Java. Ways to find difference between two LocalDateTime in Java There are multiple ways to find difference between two LocalDateTime in various time units such as Days, Months, Years etc. Using LocalDateTime’s until() method We can use LocalDateTime’s until() method to […]
05 OctoberFind 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 […]
27 SeptemberRepeat String N times in Java
Introduction In this article, we will learn how to Repeat a given String N times in Java . This is a trick question common in JAVA interviews and the candidate’s evaluation is based on different approaches he/she provides for the problem. So we will take a deep dive into looking at various ways to solve […]
26 SeptemberGet 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. package org.arpit.java2blog; import java.text.DateFormatSymbols; import java.util.Arrays; public class GetListOfWeekdayNames { public static void […]
24 SeptemberDisplay Negative Number in Parentheses in Java
In this post, we will see how to display negative number in Parentheses in Java. We can use pattern #,##0.00;(#,##0.00) with DecimalFormat‘s format() to display negative number in Parenthesis in Java. package org.arpit.java2blog; import java.text.DecimalFormat; public class DisplayNegativeNumbersInParenthesis { public static void main(String[] args) { DecimalFormat df = (DecimalFormat) DecimalFormat.getInstance(); String pattern = "#,##0.00;(#,##0.00)"; df.applyPattern(pattern); […]
24 SeptemberIncrement for Loop by 2 in Java
In this post, we will see how to increment for loop by 2 in Java. There are several looping statements available in Java and one of them is for loop in java. There are three parts of for loop. Initialization Condition Increment or decrement for (initialization; condition; increment/decrement) { //block of statements } Initialization: Initialization […]
24 SeptemberGet 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. package org.arpit.java2blog; import java.text.DateFormatSymbols; import java.util.Arrays; public class GetListOfMonths { public static void main(String[] […]
21 SeptemberConvert 0 and 1 to boolean in Java
In this post, we will see how to convert 0 and 1 to Boolean in Java. Given “0” and “1” in String datatype, convert it to boolean datatype where “0” represents false “1” represents true Convert 0 and 1 to Boolean in Java Here is program to convert 0 and 1 to boolean in Java […]