package com.fs.utils; public class DateUtils { public static java.sql.Date changeDate(java.util.Date date){ if (date ==null){ throw new RuntimeException("date不能为空:"+date); } return new java.sql.Date(date.getTime()); } } //用如下测试
import com.fs.utils.DateUtils; import java.util.Date; public class test { public static void main(String[] args) { Date utilDate =new Date(); java.sql.Date sqlDate = DateUtils.changeDate(utilDate); System.out.println(java.util.Date.class.isInstance(utilDate)); System.out.println(java.util.Date.class.isInstance(sqlDate)); System.out.println(java.sql.Date.class.isInstance(sqlDate)); System.out.println(java.sql.Date.class.isInstance(utilDate)); } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)