我速购,中国牧羊犬俱乐部,张智霖的儿子
1.calendar 转化 string
calendar calendat = calendar.getinstance(); simpledateformat sdf = new simpledateformat("yyyy-mm-dd"); string datestr = sdf.format(calendar.gettime());
2.string 转化calendar
string str="2012-5-27"; simpledateformat sdf= new simpledateformat("yyyy-mm-dd"); date date =sdf.parse(str); calendar calendar = calendar.getinstance(); calendar.settime(date);
3.date 转化string
simpledateformat sdf= new simpledateformat("yyyy-mm-dd"); string datestr=sdf.format(new date());
4.string 转化date
string str="2012-5-27"; simpledateformat sdf= new simpledateformat("yyyy-mm-dd"); date date= sdf.parse(str);
5.date 转化calendar
calendar calendar = calendar.getinstance(); calendar.settime(new java.util.date());
6.calendar转化date
calendar calendar = calendar.getinstance(); java.util.date date =calendar.gettime();
7.string 转成 timestamp
timestamp ts = timestamp.valueof("2012-1-14 08:11:00");
8.date 转 timestamp
simpledateformat df = new simpledateformat("yyyy-mm-dd hh:mm:ss"); string time = df.format(new date()); timestamp ts = timestamp.valueof(time);
以上这篇实例讲解string date calendar之间的转换就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
浅析我对 String、StringBuilder、StringBuffer 的理解
使用IDEA搭建SSM框架的详细教程(spring + springMVC +MyBatis)
Springboot整合freemarker 404问题解决方案
引入mybatis-plus报 Invalid bound statement错误问题的解决方法
网友评论