博客
关于我
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/

你可能感兴趣的文章
Objective-C实现DisjointSet并查集的算法(附完整源码)
查看>>
Objective-C实现djb2哈希算法(附完整源码)
查看>>
Objective-C实现DNF排序算法(附完整源码)
查看>>
Objective-C实现doomsday末日算法(附完整源码)
查看>>
Objective-C实现double factorial iterative双阶乘迭代算法(附完整源码)
查看>>
Objective-C实现double factorial recursive双阶乘递归算法(附完整源码)
查看>>
Objective-C实现double hash双哈希算法(附完整源码)
查看>>
Objective-C实现double linear search recursion双线性搜索递归算法(附完整源码)
查看>>
Objective-C实现double linear search 双线性搜索算法(附完整源码)
查看>>
Objective-C实现double sort双重排序算法(附完整源码)
查看>>
Objective-C实现DoublyLinkedList双链表的算法(附完整源码)
查看>>
Objective-C实现DoublyLinkedList双链表算法(附完整源码)
查看>>
Objective-C实现DPLL(davisb putnamb logemannb loveland)算法(附完整源码)
查看>>
Objective-C实现DWT离散小波变换(附完整源码)
查看>>
Objective-C实现Edmonds-Karp算法(附完整源码)
查看>>
Objective-C实现EEMD算法(附完整源码)
查看>>
Objective-C实现elgamal 密钥生成器算法(附完整源码)
查看>>
Objective-C实现EM算法(附完整源码)
查看>>
Objective-C实现EM算法(附完整源码)
查看>>
Objective-C实现entropy熵算法(附完整源码)
查看>>