java 中国标准时间_Sun Jan 05 2020 00:00:00 GMT 0800 (中国标准时间) 时间转换为 2020-01-05 08:00:00...
转换yyyy-MM-dd HH:mm:ss( DateUtil)
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.regex.Pattern;
/**
* @program: miyou_WeChat
* @description
* @author: WangTianLiang
* @create: 2020-01-20 16:59
**/
public class DateUtil {
public final static String FORMAT_STRING = "yyyy-MM-dd HH:mm:ss";
public final static String[] REPLACE_STRING = new String[]{"GMT+0800", "GMT+08:00"};
public final static String SPLIT_STRING = "(中国标准时间)";
public final static String FORMAT_STRING2 = "EEE MMM dd yyyy HH:mm:ss z";
/**
* 时间解析 Sun Jan 05 2020 00:00:00 GMT 0800 (中国标准时间)
*
* @param dateString
* @return
*/
public static String timeCycle(String dateString) {
try {
dateString = dateString.split (Pattern.quote (SPLIT_STRING))[0].replace (REPLACE_STRING[0], REPLACE_STRING[1]);
//转换为date
SimpleDateFormat sf1 = new SimpleDateFormat (FORMAT_STRING2, Locale.ENGLISH);
Date date = sf1.parse (dateString);
return new SimpleDateFormat (FORMAT_STRING).format (date);
} catch (Exception e) {
throw new RuntimeException ("时间转化格式错误" + "[dateString=" + dateString + "]" + "[FORMAT_STRING=" + FORMAT_STRING + "]");
}
}
/**
* 测试
*
* @param args
*/
public static void main(String[] args) {
String date = parseTimeZone ("Sun Jan 05 2020 00:00:00 GMT 0800 (中国标准时间)");
System.out.println (date); //输出结果 2020-01-05 08:00:00
}
}
天亮了叫你
发布了3 篇原创文章 · 获赞 1 · 访问量 335
私信
关注
标签:00,STRING,05,FORMAT,dateString,2020,public,String
来源: https://blog.csdn.net/weixin_44954939/article/details/104054838
java 中国标准时间_Sun Jan 05 2020 00:00:00 GMT 0800 (中国标准时间) 时间转换为 2020-01-05 08:00:00...相关推荐
- 时间格式转换 Mon Aug 17 2020 16:29:29 GMT+0800 (中国标准时间)
留个记录,回头直接拿着用 // Mon Aug 17 2020 16:29:29 GMT+0800 (中国标准时间) 转 年月日时分秒 function timeD(time) { let d ...
- Sun Jan 05 2020 00:00:00 GMT 0800 (中国标准时间) 时间转换为 2020-01-05 08:00:00
转换yyyy-MM-dd HH:mm:ss( DateUtil) import java.text.SimpleDateFormat; import java.util.Date; import ja ...
- 将Element UI的时间选择器(DatePicker)的Sat Jan 01 2022 00:00:00 GMT+0800 (中国标准时间)转化为XXXX-XX-XX的格式
将Sat Jan 01 2022 00:00:00 GMT+0800 (中国标准时间)转化为XXXX-XX-XX的格式 在使用element UI的时间选择器时,控制台输出的是Sat Jan 01 2 ...
- 亲测:如何将Sat Mar 14 2020 00:00:00 GMT+0800 (中国标准时间)转换成正常格式yy-MM-dd。字符串日期的比较compareTo方法。
public static void main(final String[] args) { final SimpleDateFormat sdFormat=new SimpleDateFormat( ...
- Tue Nov 24 2020 00:00:00 GMT 0800 (中国标准时间)变成yyyy-MM-dd格式
element中日期选择器获取各式为yyyy-MM-dd <el-col :span="11"><el-date-picker type="date&q ...
- 格林时间:Thu May 18 2017 00:00:00 GMT+0800 (中国标准时间) 格式转换
类似Thu May 18 2017 00:00:00 GMT+0800 (中国标准时间)格式的时间转换成2017/05/18 或取其时分秒,方法如下: /** * @param datdString ...
- 【Date】日期格式转换 Thu Sep 07 2017 00:00:00 GMT+0800 (中国标准时间) 00:00:00
/*** @Description: 将一个诡异的原始字符串格式的日期改成想要的日期格式 * @author liujunran* @date 2018年1月5日 上午11:09:18 * @vers ...
- Tue Sep 03 2019 00:00:00 GMT+0800 (中国标准时间)怎么变成时间戳
问题说明 js收到数据var a="Tue Sep 03 2019 00:00:00 GMT+0800 (中国标准时间),Sun Oct 06 2019 00:00:00 GMT+0800 ...
- 格林威治时间转换成北京时间,Mon May 10 2021 15:34:42 GMT+0800 (中国标准时间) TO 2021/5/10
public class DateUtil {public final static String FORMAT_STRING = "yyyy-MM-dd HH:mm:ss";pu ...
最新文章
- 多线程编程 - GCD
- 2 resize 到指定大小_阿里巴巴为什么让初始化集合时必须指定大小?
- linux 共享内存_盘点那些linux 后台开发类常见问题及知识点
- Oracle伪列ROWID和ROWNUM
- android不同Activity之间的数据共享
- C#中return语句的使用方法
- 完整的开发一个ContentProvider步骤
- 检索 COM 类工厂中 CLSID 为{00024500-0000-0000-C000-000000000046} 的组件时失败
- ie11安装程序无法继续 因为你的计算机,ie11无法安装解决方法详解
- 如何快速实现人脸识别通道?一文了解具体技巧
- 玩游戏计算机虚拟内存怎么设置,多少虚拟内存设置适合玩游戏(多少虚拟内存设置适合)...
- fclose_fclose –关闭流
- uefi如何安装linux系统教程,UEFI启动模式下安装Ubuntu教程
- 桌面上的计算机图片怎么复制,怎么把一张普通的图片复制到EXCEL表格中
- 微信领取淘宝内部优惠券教程免费
- ElasticSearch用法和IK分词器
- GUI界面的视频帧提取
- Java基础入门--学习笔记
- linux自动创建设备节点
- 等级保护测评之MySQL安全漏洞