java

In this lesson, you will learn to convert String to LocalDate and LocalDateTime objects. LocalDate and LocalDateTime are immutable date-time objects representing a date and a date and time. To convert String to one of the two Date objects, the provided String must represent a valid date or time according to ISO_LOCAL_DATE or ISO_LOCAL_DATE_TIME.  Otherwise, a DateTimeParseException will…

Read More Convert String to Date in Java

We can convert boolean to String in Java using the following methods: String.valueOf() method Boolean.toString() method Convert boolean to String in Java using the String.valueOf() method There are multiple overloaded versions of the valueOf() method from the String class. We will use the one which accepts boolean. Example class Test { public static void main(String[] args)…

Read More Convert boolean to String in Java

To convert String to boolean in Java, you can use one of the following methods: Boolean.parseBoolean() method BooleanUtils.toBoolean() method Boolean.valueOf() method if we need a Boolean object instead of a primive Convert String to boolean in Java using the Boolean.parseBoolean() method With the parseBoolean(String s) method of the Boolean class, if we want to get…

Read More Convert Java String to boolean

We can convert Octal to Decimal in Java in the following ways: Using the parseInt() method Using custom logic Convert Octal to Decimal in Java using the parseInt() method Integer class has a method parseInt(String s, int radix) that parses the String argument as a signed integer in the radix specified by the second argument. Example class Test…

Read More Convert Octal to Decimal in Java

We can convert float to String in Java using the following methods: String.valueOf() method Float.toString() method Convert float to String in Java using the String.valueOf() method There are multiple overloaded versions of the valueOf() method from the String class. We will use the one which accepts float. Example class Test { public static void main(String[] args)…

Read More Convert float to String in Java

Converting a Java String to a Double is a common task in Java programming. Whether you need to perform mathematical calculations or simply display numeric values, it’s important to know how to convert Strings to Doubles accurately and efficiently. In this tutorial, I will guide you through the process of converting a Java String to…

Read More Java String to a Double Conversion: Tips and Best Practices

In one of the previous posts, we covered the conversion of a Decimal to Hexadecimal. Here, you will learn how to convert Hexadecimal to Decimal in Java. We will explore the following ways: Using the parseInt() method Using custom logic Convert Hexadecimal to Decimal in Java using the parseInt() method Integer class has a static…

Read More Convert Hexadecimal to Decimal in Java