Convert LocalDate to Timestamp in Java [2 ways]
Java Hungry
by Subham Mittal
1w ago
In this post, I will be sharing how to convert LocalDate to Timestamp in Java with examples. There are two ways to achieve our goal of converting LocalDate to Timestamp in Java: 1. Using LocalDate class atTime() method [Recommended] 2. Using LocalDateTime class of() method Read Also: Convert LocalDate to Instant in Java Convert LocalDate to Timestamp in Java 1. Using LocalDate class atTime() method We can easily convert LocalDate to Timestamp using the LocalDate class atTime() method as shown below in the example: import java.sql.Timestamp; import java.time.LocalDate; import java.time.Lo ..read more
Visit website
Convert LocalDate to Instant in Java [3 ways]
Java Hungry
by Subham Mittal
3w ago
In this post, I will be sharing how to convert LocalDate to Instant in Java with examples. There are three ways to achieve our goal of converting LocalDate to Instant in Java: 1. Using LocalDate class atTime() method 2. Using LocalDate class atStartOfDay() method 3. Using LocalDateTime.of() method Read Also: Convert Instant to LocalDate in Java Convert LocalDate to Instant in Java Converting LocalDate to Instant in Java usually is a two-step process. First, converting LocalDate into ZonedDateTime or Timestamp and then calling their toInstant() method we get Instant. 1. Using LocalDate cla ..read more
Visit website
Convert Instant to LocalDate in Java [3 ways]
Java Hungry
by Subham Mittal
1M ago
In this post, I will be sharing how to convert Instant to LocalDate in Java. There are three ways to achieve our goal of converting Instant to LocalDate in Java: 1. Using ofInstant() method [Java 9+] [Recommended] 2. Using Java8 ZoneDateTime's toLocalDate() method 3. Using the Instant class toEpochMilli() method Read Also: Instant to LocalDateTime in Java Convert Instant to LocalDate in Java In Java, a LocalDate represents a date without time or timezone information, whereas an Instant represents a specific moment in time in the UTC timezone. The task is to extract the date part from an I ..read more
Visit website
Convert LocalDateTime to Instant in Java [2 ways]
Java Hungry
by Subham Mittal
2M ago
In this post, I will be sharing how to convert LocalDateTime to Instant in Java. There are two ways to achieve our goal of converting LocalDateTime to Instant in Java: 1. Using LocalDateTime class toInstant() method [Recommended] 2. Using LocalDateTime class toEpochSecond() method Convert LocalDateTime to Instant in Java 1. Using LocalDateTime class toInstant() method We can easily convert LocalDateTime to Instant in Java using LocalDateTime.toInstant() method passing ZoneOffset as the input argument as shown below in the example: import java.time.Instant; import java.time.LocalDateTime ..read more
Visit website
Check if a Character is Alphabet or not in Java
Java Hungry
by Subham Mittal
2M ago
In this post, I will be sharing how to check if a Character is Alphabet or not in Java. There are three ways to achieve our goal of checking if a Character is Alphabet or not in Java: 1. Using isAlphabetic() method [Recommended] 2. Using if else 3. Using ternary operator Check if a Character is Alphabet or not in Java 1. Using isAlphabetic() method According to Oracle docs, the Character.isAlphabetic(int codePoint) method can be used to determine if the specified character(Unicode code point) is an alphabet as shown below in the example: public class CheckCharacterAlphabet { public ..read more
Visit website
Check if a Character is Lowercase or not in Java
Java Hungry
by Subham Mittal
7M ago
In this post, I will be sharing how to check if a Character is Lowercase or not in Java. We can easily achieve our goal of checking if a Character is Lowercase or not by using the Character.isLowerCase() method. Read Also: Check if a Character is Uppercase or not in Java Check if a Character is Lowercase or not in Java 1. Using Character class isLowerCase() method According to Oracle docs, the Character.isLowerCase() method can be used to determine if the specified character is a lowercase character. The following are examples of lowercase characters: a b c d e f g h i j k l m n o p q r s t ..read more
Visit website
Check if a Character is Uppercase or not in Java
Java Hungry
by Subham Mittal
7M ago
In this post, I will be sharing how to check if a Character is Uppercase or not in Java. We can easily achieve our goal of checking if a Character is Uppercase or not by using the Character.isUpperCase() method. Read Also: char to Character in Java Check if a Character is Uppercase or not in Java 1. Using Character class isUpperCase() method According to Oracle docs, the Character.isUpperCase() method can be used to determine if the specified character is an uppercase character. The following are examples of uppercase characters: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z '\u00C0 ..read more
Visit website
Second Occurrence of Character in String in Java
Java Hungry
by Subham Mittal
8M ago
In this post, I will be sharing how to find the second occurrence of a character in a string in Java with examples. We can easily achieve our goal of finding the second occurrence of a character in a given string using the indexOf() method. Read Also: Find the last unique character of a string in Java Let's dive deep into the topic: Second Occurrence of Character in String in Java 1. Using indexOf(int ch, int fromIndex) method We can find the second occurrence of a character in a string using the indexOf(int ch, int fromIndex) method in Java. Syntax: public int indexOf(int ch, int fromInd ..read more
Visit website
Remove Last Comma from String in Java [5 ways]
Java Hungry
by Subham Mittal
8M ago
In this post, I will be sharing how to remove the last comma from String in Java. There are five ways to achieve our goal of removing the last comma from String in Java: 1. Using substring() method (Java 1.7) 2. Using substring() method (Java 8) 3. Using replaceAll() method 4. Using StringBuilder/StringBuffer 5. Using StringUtils class chop() method Read Also: Replace comma with space in Java Remove last comma from String in Java 1. Using the substring() method (Java 1.7) We can easily use the substring() method to remove last comma from String in Java as shown below in the example ..read more
Visit website
Remove Comma from Number in Java [2 ways]
Java Hungry
by Subham Mittal
8M ago
In this post, I will be sharing how to remove comma from a number in Java. There are two ways to achieve our goal of removing commas from a number: 1. Using replace() method 2. Using replaceAll() method Read Also: Convert Comma-Separated String to List in Java Remove Comma from Number in Java 1. Using replace() method We can easily remove the comma from a number using replace() method in Java as shown below in the example: public class RemoveCommaFromNumber { public static void main(String args[]) { String str1 = "123,456,789,0987,65"; str1 = str1.replace ..read more
Visit website

Follow Java Hungry on FeedSpot

Continue with Google
Continue with Apple
OR