package com.test.dateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.junit.Test;
public class Date2String {
@Test
public void test() {
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));
}
}
package com.test.dateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import org.junit.Test;
public class String2Date {
@Test
public void test() throws ParseException {
String string = "2016-10-24 21:59:06";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(sdf.parse(string));
}
}
package com.test.dateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import org.junit.Test;
public class String2Date {
@Test
public void test() throws ParseException {
String string = "2016-10-24";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(sdf.parse(string));
}
}
package com.test.dateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import org.junit.Test;
public class String2Date {
@Test
public void test() throws ParseException {
String string = "2016-10-24 21:59:06";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
System.out.println(sdf.parse(string));
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有