java--日期时间格式化
2015-04-29 15:57
295 查看
这是两个方法,1是返回日期字符串 ;2是返回日期类型
public static String getDateFormate(Date date, String formate) { String result = null; if (date == null) { return null; } SimpleDateFormat dateformate = new SimpleDateFormat(formate); result = dateformate.format(date); return result; } public static Date getDateFromStr(String dateStr, String formate) throws ParseException { Date date = null; if (dateStr == null || dateStr.equals("")) { return null; } SimpleDateFormat dateformate = new SimpleDateFormat(formate); date = dateformate.parse(dateStr); return date; }
test 测试
getDateFormate(new Date(),"yyyymmdd");
如上;
相关文章推荐
- Java格式化CST日期时间
- java中获取当前系统时间,日期并格式化输出
- java script 格式化日期时间源码
- JAVA中String.format的用法 格式化字符串,格式化数字,日期时间格式化,
- JAVA格式化时间日期
- java向MySQL插入当前时间的四种方式和java时间日期格式化的几种方法(案例说明)
- JAVA将十位时间戳格式化为日期Date类型
- Java格式化CST日期时间
- JAVA格式化日期时间
- Java魔法堂:Date与日期时间格式化
- Java使用DateFormatter格式化日期时间的方法示例
- JAVA格式化时间日期
- JAVA将十位时间戳格式化为日期Date类型
- Java格式化CST日期时间
- java 日期时间格式化
- Java常用类库——时间处理类Date、Calendar、GregorianCalendar以及日期格式化和计算
- JAVA将十位时间戳格式化为日期Date类型
- Java 9的日期时间格式化趋近Unicode区域设置标准
- java 时间和日期的格式化
- java 使用simpleDateFormat格式化日期 时间