如何将getTime()转换为'YYYY-MM-DD HH24:MI:SS' [英] How to convert getTime() to 'YYYY-MM-DD HH24:MI:SS'

查看:125
本文介绍了如何将getTime()转换为'YYYY-MM-DD HH24:MI:SS'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中有以下代码

I Have the following code in my application

System.out.println(rec.getDateTrami().getTime());

我需要转换以下格式(我想它们是秒)

I need to convert the following format (I suppose that they are seconds)

43782000
29382000
29382000

格式 YYYY-MM-DD HH24:MI:SS ,有人可以帮我吗?

To a format YYYY-MM-DD HH24:MI:SS, anyone can help to me?

推荐答案

你可以使用 SimpleDateFormat

示例:

SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Date date = new Date();
date.setTime(rec.getDateTrami().getTime());
System.out.println(format.format(date));

文档:
SimpleDateFormat
DateFormat

这篇关于如何将getTime()转换为'YYYY-MM-DD HH24:MI:SS'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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