时间戳转时间
来源:互联网 发布:csm欢网实时数据 首页 编辑:程序博客网 时间:2024/06/10 06:21
public static String getTime(long timestamp) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String time = null; try { String str = sdf.format(new Timestamp(timestamp)); time = str.substring(11, 16); String month = str.substring(5, 7); String day = str.substring(8, 10); time = getDate(month, day) + time; } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return time; } public static String getDate(String month, String day) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//24小时制 java.util.Date d = new java.util.Date(); String str = sdf.format(d); String nowmonth = str.substring(5, 7); String nowday = str.substring(8, 10); String result = null; int temp = Integer.parseInt(nowday) - Integer.parseInt(day); switch (temp) { case 0: result = "今天"; break; case 1: result = "昨天"; break; case 2: result = "前天"; break; default: StringBuilder sb = new StringBuilder(); sb.append(Integer.parseInt(month) + "月"); sb.append(Integer.parseInt(day) + "日"); result = sb.toString(); break; } return result; }
0 0
- 时间戳转时间
- 时间戳转时间
- 时间戳转时间
- 时间戳转时间
- 时间戳转时间
- 时间戳转时间
- 时间戳时间转
- 【java时间戳】时间戳转时间
- 时间戳转时间字符串和时间
- 时间转时间戳 时间戳转时间
- C#时间戳转时间-时间转时间戳
- iOS-时间戳转时间
- 关于时间戳转时间
- 时间戳转时间、日期
- mysql 时间戳转时间
- JS时间戳转时间
- Mysql时间戳转Java时间戳
- Python时间戳转Java时间戳
- mysql 重置主键
- iOS 自动布局 同一行的几个控件 需要其中某几个不被压缩,其中某几个不被拉伸
- memdup_user()函数
- 23种设计模式C++实例之装饰模式
- kettle 6.0安装并连接ORACLE,HADOOP CDH5.3.0以及hadoop客户端配置
- 时间戳转时间
- 大数据之mongodb --> (1)在ubuntu上安装mongodb
- 写时拷贝技术(copy-on-write)
- Activtity多层页面跳转,返回调用finish() 页面重复
- leetcode -- Expression Add Operators --难点再看
- Android 微信抢红包插件
- gitlab备份
- SQL中各种join的用法
- 多级反向代理下,Java获取请求客户端的真实IP地址多中方法整合