Springmvc配置时间日期转换
1.局部日期转换
@Controller
public class ProductController{
@RequestMapping(value="/test/springmvc.do")
public String test(String name,Date birthday){
System.out.println(name+birthday);
return "";
}
//局部性的转换
@InitBinder
public void initBinder(WebDataBinder binder, WebRequest request) {
// TODO Auto-generated method stub
//转换日期格式
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat,true));
}
}
2.全局性的时间转换
1).在springmvc.xml添加配置
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<!-- 日期格式转换 -->
<property name="webBindingInitializer">
<bean class="cn.itcast.core.web.DateConverter" />
</property>
</bean>
2).编写 DateConverter
public class DateConverter implements WebBindingInitializer {
public void initBinder(WebDataBinder binder, WebRequest request) {
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat,true));
}
}
Springmvc配置时间日期转换的更多相关文章
- 时间日期转换工具类,获取当前时间YYYYMMDD24HHMISS、YYYYMMDDHHMISS
YYYYMMDD24HHMISS:24小时制时间(显示上只是比YYYYMMDDHHMISS中间多了一个24),例:2018102224112440 YYYYMMDDHHMISS:12小时制时间,例20 ...
- SpringMVC配置全局日期转换器,处理日期转换异常
Spring 3.1.1使用Mvc配置全局日期转换器,处理日期转换异常链接地址: https://www.2cto.com/kf/201308/236837.html spring3.0配置日期转换可 ...
- 【MySQL笔记】字符串、时间日期转换
1.新增一列,将字符串日期(年.月.日)转换为Date类型 报错:Error Code: 1175. You are using safe update:http://jingyan.baidu. ...
- 02基于注解开发SpringMVC项目(jar包,异步,request,参数传递,多选的接收,Model传参,map传参,model传参,ajax,重定向,时间日期转换)
1 所需jar包 项目结构如下: 2 web.xml配置文件的内容如下: <?xmlversion="1.0"encoding="UTF-8"?&g ...
- PHP phpexcel 导入时间/日期转换时间戳
strtotime(gmdate('Y-m-d H:i',\PHPExcel_Shared_Date::ExcelToPHP($importtime))); /** * 判断字符串是否是日期格式 * ...
- springMVC 返回时间格式转换
<mvc:annotation-driven> <mvc:message-converters> <bean class="org.springframewor ...
- python 使用time / datetime进行时间、时间戳、日期转换
python 使用time 进行时间.时间戳.日期格式转换 #!/usr/bin/python3 # -*- coding: utf-8 -*- # @Time : 2017/11/7 15:53 # ...
- Java中时间日期格式化
1.与日期时间相关的类: 第一:java.util.Date; 将时间作为一个整体使用.处理时,使用Date类较为简便 第二:j ...
- 07、MySQL—时间日期类型
时间日期类型 1.Date 日期类型:系统使用三个字节来存储数据,对应的格式为:YYYY-mm-dd,能表示的范围是从1000-01-01 到9999-12-12,初始值为0000-00-00 2.T ...
随机推荐
- java 日期排序。。。。
Collections.sort(list, new Comparator<Map<Object, Object>>() { public int compare(Map< ...
- uva-519-拼图
给你N*M个碎片,问能否用他们拼成一个矩形,矩形的边缘要全是F,除外界边缘的边要么是I,要么O,不能是F1.碎片会重复出现,所以同样的碎片在同一个位置,如果已经不能放,直接跳过就行2.矩形的边缘要全是 ...
- mybatis一(常用配置信息和获取插入后id)
<!--配置文件--><?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE conf ...
- Flex学习笔记-自定义菜单的显示细节
icon <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx=&qu ...
- opencv画出轮廓外接矩形
Mat cannyImage; /// Detect edges using canny Canny(src, cannyImage, , , ); vector<vector<Point ...
- Mybatis:通过MapperScannerConfigurer进行mapper扫描
在applicationContext.xml里配置的
- Windows环境安装Django步骤
前提:已经安装Python 1.先从Django官网下载压缩包:https://www.djangoproject.com/download/ 2.解压Django,如我解压到 D:\Python\D ...
- mongodb学习-练习实例
C:\Users\issuser>mongoMongoDB shell version: 2.4.6connecting to: test> db.user.find(){ "_ ...
- jsfl 生成flash 工具面板
利用flash组件的List做界面,先从flash中拖出List组件,然后删除.绑定Main类. package { import flash.display.Sprite; import flash ...
- ACM__容器之vector
今天做题碰到了深搜的题,有一种存图方式需要用到vector,对vector不是很熟悉,回顾了一下 vector都知道是一个容器,但并不准确,它是一个多功能的能够操作多种数据结构和算法的模板类和函数库. ...