Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,895 questions

51,826 answers

573 users

How to parse string into Date in Java

1 Answer

0 votes
import java.text.SimpleDateFormat; 
import java.util.Date;
import java.text.ParseException;

public class MyClass {
    public static void main(String args[]) {
      SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd"); 
      String s = "2021-03-24";

      try {
            Date dt = ft.parse(s); 
		    System.out.println(dt);    

      } catch (ParseException e) { 
            e.printStackTrace();
        }
    }
}



/*
run:

Wed Mar 24 00:00:00 GMT 2021

*/

 



answered Mar 24, 2021 by avibootz

Related questions

1 answer 172 views
2 answers 92 views
92 views asked Oct 8, 2023 by avibootz
4 answers 249 views
1 answer 106 views
1 answer 128 views
...