zoukankan      html  css  js  c++  java
  • Java时间操作(一):关于UTC格式时间处理

    Java中获取形如:20160811T122132+08 格式,可以通过如下方法

    package com.mc.others;

    public class UTCTimeTest {
    @Test
    public void test1() {
    Calendar calendar = Calendar.getInstance();
    DateFormat dtf = new SimpleDateFormat("yyyyMMdd'T'HHmmssZ");
    Date now = calendar.getTime();
    String format = dtf.format(now);
    System.out.println(format);//20160803T222649+0800
    }
    @Test
    public void test2() {
    Date now = new Date();
    DateFormat dtf = new SimpleDateFormat("yyyyMMdd'T'HHmmssZZ");
    String format = dtf.format(now);
    System.out.println(format);//20160803T221641+0800
    }
    @Test
    public void test3() {
    // org.joda.time.DateTime;
    DateTime dateTime = new DateTime();
    String format = dateTime.toString();
    System.out.println(format);//2016-08-03T22:14:19.293+08:00
    }
    @Test
    public void test4() {
    DateTime dateTime = new DateTime();
    String format = dateTime.toString("yyyyMMdd'T'HHmmssZZ");//20160803T221822+08:00
    System.out.println(format);
    }
    }
  • 相关阅读:
    TiDB架构特性
    TiDB入门
    ansible安装nginx
    linux命令之cowsay
    KeepAlived 搭建高可用的HAProxy集群
    HAProxy 实现镜像队列的负载均衡
    RabbitMQ高可用集群介绍
    docker安装phpMyAdmin
    centos7安装RabbitMQ
    Vim轻量级查看Java代码
  • 原文地址:https://www.cnblogs.com/LiuChunfu/p/5734928.html
Copyright © 2011-2022 走看看