Answers for "convert string to datetime java 8"

5

How to convert string to date in Java 8

// How to convert string to date in Java 8
import java.time.LocalDate;
import java.time.LocalDateTime;
public class Java8StringToDate
{
   public static void main(String[] args)
   {
      DateTimeFormatter dtf1 = DateTimeFormatter.ofPattern("d/MM/yyyy");
      String strDate1 = "14/05/2005";
      LocalDate ld1 = LocalDate.parse(strDate1, dtf1); 
      System.out.println(ld1);
      DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("MMM d yyyy");
      String strDate2 = "May 14 2005";
      LocalDate ld2 = LocalDate.parse(strDate2, dtf2); 
      System.out.println(ld2);
   }
}
Posted by: Guest on February-22-2021
1

convert string into time in java

java.sql.Time timeValue = new java.sql.Time(formatter.parse(fajr_prayertime).getTime());
Posted by: Guest on March-07-2021

Code answers related to "convert string to datetime java 8"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language