util的date
public class Date1 {
public static void main(String[] args) throws ParseException {
Date date=new Date();
String localeString = date.toLocaleString();
System.out.println(localeString);
System.out.println(date.getTime());
SimpleDateFormat sdf=new SimpleDateFormat("yyyy;MM;dd;;hh;mm;ss");
String ss=sdf.format(date);
Date date2=new Date(1498481243639l);
System.out.println(date2);
}
}
public static void main(String[] args) throws ParseException {
Date date=new Date();
System.out.println(date.toLocaleString());
long time = date.getTime();
System.out.println(time);
Date date2 = new Date(1498464859777l);
System.out.println(date2);
String dString="2015-12-12 20:53:12";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dd="2017-06-25 16:20:26";
Date date2 = simpleDateFormat.parse(dd);
System.out.println(date2);
}
数据库中的date
util 转 sql
String datea = t_news.getDatea();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Date parse = simpleDateFormat.parse(datea);
Timestamp timestamp = new Timestamp(parse.getTime());
pst.setTimestamp(4,timestamp);
util 转 sql 日期
Date date = new Date();
Timestamp timestamp = new Timestamp(date.getTime());
util 转 sql 日期
String birthday = person.getBirthday();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
java.util.Date date = sdf.parse(birthday);
Date bt=new Date(date.getTime());
sql 转 util 日期
Timestamp timestamp = rs.getTimestamp(5);
String localeString = timestamp.toLocaleString();
sql 转 util 日期
Date date = rs.getDate(3);
SimpleDateFormat simpleDateFormat =new SimpleDateFormat("yyyy-MM-dd");
String birthday = simpleDateFormat.format(date);
jsp中data
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>测试jstl格式化库</h1>
<hr>
<li>测试日期的格式化</li><br>
today(default):<fmt:formatDate value="${today}"/><br>
today(type="date"):<fmt:formatDate value="${today}" type="date"/><br>
today(type="time"):<fmt:formatDate value="${today}" type="time"/><br>
today(type="both"):<fmt:formatDate value="${today}" type="both"/><br>
today(dateStyle="short"):<fmt:formatDate value="${today}" dateStyle="short"/><br>
today(dateStyle="medium"):<fmt:formatDate value="${today}" dateStyle="medium"/><br>
today(dateStyle="long"):<fmt:formatDate value="${today}" dateStyle="long"/><br>
today(dateStyle="full"):<fmt:formatDate value="${today}" dateStyle="full"/><br>
today(pattern="yyyy/MM/dd HH:mm:ss"):<fmt:formatDate value="${today}" pattern="yyyy/MM/dd HH:mm:ss"/><br>
today(pattern="yyyy/MM/dd HH:mm:ss"):<fmt:formatDate value="${today}" pattern="yyyy/MM/dd HH:mm:ss" var="d"/><br>
${d }<br>
测试日期的格式化
today(default):2017-8-23
today(type="date"):2017-8-23
today(type="time"):11:41:30
today(type="both"):2017-8-23 11:41:30
today(dateStyle="short"):17-8-23
today(dateStyle="medium"):2017-8-23
today(dateStyle="long"):2017年8月23日
today(dateStyle="full"):2017年8月23日 星期三
today(pattern="yyyy/MM/dd HH:mm:ss"):2017/08/23 11:41:30
today(pattern="yyyy/MM/dd HH:mm:ss"):
2017/08/23 11:41:30
</body>
</html>*/