java conversion

In the previous post, we covered a String to Date conversion. In this post, you will learn to convert LocalDate and LocalDateTime to String in Java. LocalDate and LocalDateTime are immutable date-time objects that represent a date and a date and time. Convert LocalDate to String in Java Below is the program that parses a LocaDate object to a String using…

Read More Convert LocalDate and LocalDateTime to String in 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 Java String to Date

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

We can convert Double to String in Java using the following methods: String.valueOf() method Double.toString() method Convert Double 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 double. Example class Test { public static void main(String[] args)…

Read More Convert Double to String in Java