在 JSP 中转换和格式化日期 [英] Convert and format a Date in JSP

查看:24
本文介绍了在 JSP 中转换和格式化日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从我的 JSP 页面,我得到了这种格式的 Date.

From my JSP Page, I am getting Date in this format.

2011 年 5 月 13 日星期五 19:59:09 GMT 0530(印度标准时间)

Fri May 13 2011 19:59:09 GMT 0530 (India Standard Time)

如何将其转换为模式 yyyy-MM-dd HH:mm:ss?

How can I convert this to the pattern yyyy-MM-dd HH:mm:ss?

推荐答案

您可以使用 SimpleDateFormat 类来做到这一点.

You can do that using the SimpleDateFormat class.

SimpleDateFormat formatter=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

String dates=formatter.format(mydate);
//mydate is your date object

这篇关于在 JSP 中转换和格式化日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆