How to convert string "Monday, 10 January 2017 | 04:58 PM" to a java.sql.Date 2017-01-10?
            Asked
            
        
        
            Active
            
        
            Viewed 162 times
        
    -3
            
            
        - 
                    2Stack Overflow has hundreds of Questions about parsing a String as a date-time. How do those not solve your problem? – Basil Bourque Jan 11 '17 at 03:35
 
1 Answers
0
            
            
        Use SimpleDateFormat:
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
class Main {
  public static void main(String[] args) {
    try {
      SimpleDateFormat format = new SimpleDateFormat("EEEEEE, dd MMMMMMM yyyy | hh:mm a");
      Date parsed = format.parse("Monday, 10 January 2017 | 04:58 PM");
      java.sql.Date sql = new java.sql.Date(parsed.getTime());
    } catch (ParseException e){
      e.printStackTrace();
    }
  }
}
        Sash Sinha
        
- 18,743
 - 3
 - 23
 - 40