往数据库存date数据

2022/3/26 2:22:45

本文主要是介绍往数据库存date数据,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

Dataformat  form1 = new SimpleDateFormat("yyyy-MM-dd");
String birday = req.getParameter("birthday");
Date date = form1.parse(birday);

  把String类型的改成date类型

 Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        System.out.println(sdf.format(date));
        sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println(sdf.format(date));
        sdf = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
        System.out.println(sdf.format(date));

  把date转成String



这篇关于往数据库存date数据的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程