在Java中格式化时间戳 [英] Formatting Timestamps in Java

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

问题描述

有没有办法将UTC时间格式化为我想在java中使用的任意字符串格式?基本上我正在考虑让一些类采取时间戳,我通过它是字符串告诉它我想要它形成,它返回格式化的字符串为我。有没有办法这样做?

Is there a way to format a UTC time into any arbitrary string format I want in java? Basically I was thinking of having some class take the timestamp and I pass it is string telling it how I want it formated, and it returns the formatted string for me. Is there a way to do this?

推荐答案

java.text.SimpleDateFormat类提供了语言环境中日期的格式化和解析,

The java.text.SimpleDateFormat class provides formatting and parsing for dates in a locale-sensitive manner.

SimpleDateFormat 是一个很好的详细信息来源。还有一个 Java教程,其中包含示例用法。

The javadoc header for SimpleDateFormat is a good source of detailed information. There is also a Java Tutorial with example usages.

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

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