String与Date转换
public class TimeTraining {
public static void changeStr(String str){
str = "137878";
}
public static void main(String[] args){
Date cur = new Date();
SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String date = ft.format(cur); //format(convert time to string);
System.out.println(date);
try {
Date tdate = ft.parse(date); //format(convert String to time);
System.out.println(tdate);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
String与Date转换的更多相关文章
- java String和Date转换
SimpleDateFormat函数语法: G 年代标志符 y 年 M 月 d 日 h 时 在上午或下午 (1~12) H 时 在一天中 (0~23) m 分 s 秒 S 毫秒 ...
- 【java】String与Date转换
String转Date String date=""; SimpleDateFormat format=new SimpleDateFo ...
- 时间戳、String、Date转换
时间戳(String or long) =>Date long s=1557230621043L; Date date=new Date(s); System.out.println(date) ...
- String和Date、Timestamp之间的转换
一.String与Date(java.util.Date)互转 1.1 String -> Date String dateStr = "2010/05/04 12:34:23&quo ...
- Java:String和Date、Timestamp之间的转换
一.String与Date(java.util.Date)互转 1.1 String -> Date String dateStr = "2016-9-28 12:25:55" ...
- Java String和Date的转换
String—>Date方法一: String dateString = "2016-01-08"; try { SimpleDateFormat sdf = new Sim ...
- Java String和Date的转换 Date类型操作
String—>Date String dateString = "2012-12-06 "; try { SimpleDateFormat sdf = new Simple ...
- SimpleDateFormat实现String与Date之间的转换
基本用法: java.text.SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd"); java.util.Date ...
- String、Date、Calendar之间的转换
1.String.Date.Calendar之间的转换 要用到格式化类SimpleDateFormat package com.rong.se; import java.text.ParseExcep ...
随机推荐
- [HDU1109]模拟退火算法
模拟退火的基本思想: (1) 初始化:初始温度T(充分大),初始解状态S(是算法迭代的起点),每个T值的迭代次数L (2) 对k=1,……,L做第(3)至第6步: (3) 产生新解$S\prime $ ...
- 在虚拟机中的Ubuntu搭建java开发环境
前提: 安装好虚拟机 在虚拟机中装好了Ubuntu系统 以上两步请参见我的博客(python进阶) 1 安装JDK 1.1 到官网下载jdk压缩包并保存在本地 jdk1.8:点击前往 1.2 在Ubu ...
- hdu1067
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #inclu ...
- js常用util
/** 日期格式化 */Date.prototype.Format = function(format) { var o = { "M+" : this.getMonth() + ...
- .net Core命令行,Json配置
创建.netCore控制台 NuGet :Microsoft.AspNetCore.All static void Main(string[] args) { var builder = new Co ...
- kolla-ansible安装cinder
LVM后端 环境拓扑 节点 IP 主机名 Controller/Network/Apollo 92.0.0.11 anode Compute/Storage 92.0.0.12 bnode multi ...
- How to modify rosbag?如何修改rosbag?
Ubuntu16.04,kinetic 本文示例修改使用rosbag中的frame id 在http://wiki.ros.org/bag_tools中,能找到 change_camera_info. ...
- Docker容器构建过程的安全性分析
来源:嘶吼专业版 ID:Pro4hou DevOps概念的流行跟近些年微服务架构的兴起有很大关系,DevOps是Dev(Development)和Ops(Operations)的结合,Dev负责开发, ...
- tp5.1 手动引入外部类库
use think\facade\Env; require_once Env::get('ROOT_PATH')."extend/PHPExcel/Classes/PHPExcel.php& ...
- libaudit_plugin.so安装
#上传audit到mysql的plugin目录vim /etc/my.cnfplugin-load=AUDIT=libaudit_plugin.soaudit_json_file=1audit_jso ...