Introduction In this article, we will learn how to convert java.util.Date to java.sql.Date Example: import java.util.Calendar; import java.util.Date; public class DateConversion { public static void main(String[] args) { Date date = Calendar.getInstance().getTime(); java.sql.Date sqlDate = new java.sql.Date( date.getTime()); } } Please note that both these Date classes are outdated now. Use java.Time classes instead of legacy java.util.Date & java.sql.Date with JDBC 4.2 or later. Use Instant class instead of java.util.Date Use LocalDate instead of java.sql.Date
Blog about programming