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 custom formatted date string into Date object in Java

1 Answer

0 votes
package javaapplication1;

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

public class JavaApplication1 {

    public static void main(String[] args) {

        SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");

        try {
            Date date = sdf.parse("31/10/2016");
            System.out.println(date);
        } catch (ParseException pe) {
            System.out.println(pe.getMessage());
        }
    }
}
   
/*
   
run:
   
Mon Oct 31 00:00:00 IST 2016
   
*/

 



answered Oct 31, 2016 by avibootz

Related questions

1 answer 141 views
141 views asked Mar 24, 2021 by avibootz
1 answer 166 views
2 answers 230 views
1 answer 139 views
139 views asked Aug 5, 2017 by avibootz
3 answers 287 views
...