我有包含 utc 秒的数据库。我需要为按日过滤器、按小时过滤器和周末、工作日过滤器编写一个 mysql 查询。
最佳答案
请检查这个..
Date date = new Date(1451114203L);
DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
format.setTimeZone(TimeZone.getTimeZone("Asia/Calcutta"));
String formatted = format.format(date);
System.out.println(formatted);
使用 MYSQL
SELECT from_unixtime(1451114203) ;
SELECT from_unixtime(1451114203, '%Y %D %M %h:%i:%s %a') ;
引用 Convert Unix timestamp into human readable date using MySQL
关于java - 如何将mysql中的时间转换为时区特定时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34469281/