java simpledateformat JAVA SIMPLEDATEFORMAT 자바 심플데이타 포맷
1. Date to String
======================================================
Date now = new Date();
String strnow ="";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
strnow = sdf.format(now);
Log.d("xxx"," strnow "+strnow);
2. String to Date
======================================================
try {
Date ddate = new Date();
String strdate= "2017-09-09 11:11:11";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
ddate = sdf.parse(strdate);
Log.d("xxx","ddate "+ddate .toString());
} catch (ParseException e) {
e.printStackTrace();
}
3. SimpleDateFormat
======================================================
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss a");
======================================================
Date now = new Date();
String strnow ="";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
strnow = sdf.format(now);
Log.d("xxx"," strnow "+strnow);
2. String to Date
======================================================
try {
Date ddate = new Date();
String strdate= "2017-09-09 11:11:11";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
ddate = sdf.parse(strdate);
Log.d("xxx","ddate "+ddate .toString());
} catch (ParseException e) {
e.printStackTrace();
}
3. SimpleDateFormat
======================================================
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss a");
댓글
댓글 쓰기