Search results for: Java

public static <T> Mono<T> just(T data) import reactor.core.publisher.Mono; class ReactiveJavaTutorial { public static void main(String[] args) { Mono<String> mono = Mono.just(“Hello”); } } import org.reactivestreams.Publisher; import reactor.core.publisher.Mono; class ReactiveJavaTutorial { public static void main(String[] args) { Publisher<String> mono = Mono.just(“Hello”); } } import reactor.core.publisher.Mono; class ReactiveJavaTutorial { public static void main(String[] args) { // will…

Read More Create a Mono in Java Reactor

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. Both of the examples below make use of java.time package. For more information about Java packages, check out our…

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 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