java date 日期格式_如何将JAVA DATE类型的日期 转换成指定格式类型的 (如:YYYY-MM-DD) 的 DATE类型数据?...

Java中的Date类型无法直接设置格式,需要通过SimpleDateFormat转换为String。例如,可以使用`SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())`将日期转换为指定格式。同时,可以通过解析字符串来构建日期,如利用Calendar类进行月份、日期等的设置。
摘要由CSDN通过智能技术生成

展开全部

Date类型并没有格式32313133353236313431303231363533e58685e5aeb931333433653262,只有转换成String格式的时候让格式化显示。

new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")format(new Date());

Calendar calendar = Calendar.getInstance();

int year = Integer.parseInt(datetime.substring(0,4));

int month = Integer.parseInt(datetime.substring(5,7));

int date = Integer.parseInt(datetime.substring(8,10));

int hour = Integer.parseInt(datetime.substring(11,13));

int minute = Integer.parseInt(datetime.substring(14,16));

//int second = Integer.parseInt(datetime.substring(17,19));

if(calendar.get(Calendar.YEAR)>year){

int y = calendar.get(Calendar.YEAR)-year;

9332d79d5ec0415661e1aeee6bf3adf6.png

扩展资料:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值