Formatting Timestamps in Java

前端 未结 4 1677
刺人心
刺人心 2020-12-11 00:12

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 strin

4条回答
  •  清歌不尽
    2020-12-11 00:54

    The DateFormat class or SimpleDateFormat should get you there. For example, http://www.epochconverter.com/ lists the following example to convert a epoch time to human readable timestamp with Java:

    String date = new java.text.SimpleDateFormat("dd/MM/yyyy HH:mm:ss").format(new java.util.Date (epoch*1000));
    

提交回复
热议问题