博客
关于我
Java处理时间Date
阅读量:541 次
发布时间:2019-03-09

本文共 1102 字,大约阅读时间需要 3 分钟。

import java.text.DateFormat;import java.text.ParseException;import java.text.SimpleDateFormat;import java.util.Date;public class DateParserT {    public static void main(String[] args) {        Date dt = new Date();        System.out.println(dt); // 格式:Wed Jul 06 09:28:19 CST 2016        String formatDate = null;        String dateStr = "2016-07-06";        String FormatStr = "yyyy-MM-dd";        SimpleDateFormat dFormat = new SimpleDateFormat(FormatStr);        try {            Date date = dFormat.parse(dateStr);            System.out.println(date);// 格式:2016-07-06            System.out.println(dFormat.format(date));        } catch (ParseException e) {            e.printStackTrace();        }        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");        SimpleDateFormat sdf2 = new SimpleDateFormat("HHmmss");        Date currentTime = new Date();        String datastring = sdf.format(currentTime); // 格式:20160706094333        String onlyStr = datastring.replace(" ", "");        String subStr = onlyStr.substring(1); // 格式:1467770970        System.out.println(subStr);    }}

转载地址:http://reliz.baihongyu.com/

你可能感兴趣的文章
netty底层源码探究:启动流程;EventLoop中的selector、线程、任务队列;监听处理accept、read事件流程;
查看>>
Netty心跳检测
查看>>
Netty心跳检测机制
查看>>
Netty核心模块组件
查看>>
Netty框架内的宝藏:ByteBuf
查看>>
Netty框架的服务端开发中创建EventLoopGroup对象时线程数量源码解析
查看>>
Netty源码—2.Reactor线程模型一
查看>>
Netty源码—3.Reactor线程模型三
查看>>
Netty源码—4.客户端接入流程一
查看>>
Netty源码—4.客户端接入流程二
查看>>
Netty源码—5.Pipeline和Handler一
查看>>
Netty源码—5.Pipeline和Handler二
查看>>
Netty源码—6.ByteBuf原理一
查看>>
Netty源码—6.ByteBuf原理二
查看>>
Netty源码—7.ByteBuf原理三
查看>>
Netty源码—7.ByteBuf原理四
查看>>
Netty源码—8.编解码原理一
查看>>
Netty源码—8.编解码原理二
查看>>
Netty源码解读
查看>>
netty的HelloWorld演示
查看>>