Posts

Showing posts from 2024

How to convert a string to a SQL date

Image
  Steps SimpleDateFormat  - create a class that encapsulates the format of the date you are creating.  Parse the date sent using the method to ensure it meets date formatting requirements. Throw a parse exception if the date is invalid. Create a sqlDate from the parsed date. Use the number of milliseconds from  January 1, 1970, 00:00:00 GMT as an input into the method. This ensures the accuracy of the formed SQL date. Return the sqlDate to the method caller.