java 不同时间格式转化】的更多相关文章

今天项目中遇到一个格式问题,收到的timestamp格式是2019-08-19-16:03:21 , 但是入es时,当类型为date的时候,这种格式直接报错,因为索引建的格式是yyyy-MM-dd HH:mm:ss,即中间多了一个横杠. 解决思路,先把时间转化成Date类型,然后再把Date转成字符串的类型. String --> Date /** * @Title: 字符串转日期 * @MethodName: parse * @Description: * @param @param strD…
--.SQL时间格式转化 --日期转换参数 ) --2009-03-15 15:10:02 ),'-',''),' ',''),':','') ) , ) --2009/03/15 ) , ) ) , ) --2009.03.15 ) , ) --15:13:26 其它我不常用的日期格式转换方法: ) , ) --03/15/2009 ) , ) --15/03/2009 ) , ) --15.03.2009 ) , ) --15-03-2009 ) , ) --15 03 2009 ) , )…
1)根据当前时间,获取具体的时刻的时间 N天前 M小时之前 可用 new Date().getTime() - 24 * 60 * 60 * 1000*N[N天之前]的方法来获取处理时间之后的具体的值,最终转化为想要的时间格式 import java.text.SimpleDateFormat; import java.util.Date; public class getTime { public static void main(String[] args) { SimpleDateForm…
package com; import java.text.SimpleDateFormat; import java.util.Date; /** * @author Gerrard */ public class CheckTimeHHMM { public static void main(String[] args) { boolean flg = checkTime("8:00"); boolean flg3 = checkTime("24:00"); b…
时间格式转化成string工具类: package cn.javass.util; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class DateFormatUtil { private DateFormatUtil(){} public enum DateFormatStyleEnum{ YMD("yyyy-MM-dd"),YMDHMS(&…
CST可以为如下4个不同的时区的缩写: 美国中部时间:Central Standard Time (USA) UT-6:00 澳大利亚中部时间:Central Standard Time (Australia) UT+9:30 中国标准时间:China Standard Time UT+8:00 古巴标准时间:Cuba Standard Time UT-4:00 GMT 世界时UT [1]  即格林尼治 [1]  平太阳时间,是指格林尼治所在地的标准时间,也是表示地球自转速率的一种形式 GMT指…
--A表中的日期字段 create_date   例如:2017-08-05  转化为2017年8月5日   oracle 在这里的双引号会忽略 select to_char(to_date(tt.create_date,'yyyy-MM-dd'),'yyyy"年"MM"月"dd"日"')  from  A tt; --将系统时间转化为字符串select to_CHAR(sysdate,'yyyy-MM-DD HH24:MI:SS') from…
System.out.println("Hello World!"); SimpleDateFormat format = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss");//设置时间格式 Date currentTime = new Date();//获取当前时间 String date=format.format(currentTime);//对当前时间进行格式化 currentTime=format.parse(dat…
win7系统 获得系统时间为 2015年1月1日 星期5 10:10 数据库中时间格式 是不认识的 转化为 DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); 就可以了 要注意24小时制…
时间戳转成正常日期的公式:C1=(A1+8*3600)/86400+70*365+19其中A1表示当时的1249488000时间戳数值其中C1就是所需的日期格式,C1单元格属性改成日期格式就可以了.正常日期转为时间戳格式公式:A1=(C1-70*365-19)*86400-8*3600其中C1表示正常日期时间格式:其中A1就是所需的时间戳格式,A1单元格属性日期格式转成常规格式就可以了.…
时间格式转换SimpleDateFormat: //定义日期的格式 SimpleDateFormat format =new SimpleDateFormat("yyMMdd"); //将当前时间转换成上述格式 format.format(Calendar.getInstance().getTime());  y 年  M 月  d 日  h 时 在上午或下午 (1~12)  H 时 在一天中 (0~23)  m 分  s 秒  S 毫秒  E 星期  D 一年中的第几天  F 一月中…
js里面要用可以用伊尔表达式,循环是用js: document.getElementById("${pj.pltime }").innerHTML = dateToGMT("${pj.pltime }"); <div class="order-info"> <p id="${pj.pltime}"> <script type="text/javascript"> func…
1.获取秒级时间戳与毫秒级时间戳.微秒级时间戳 import time import datetime t = time.time() print (t) #原始时间数据 print (int(t)) #秒级时间戳 print (int(round(t * 1000))) #毫秒级时间戳 print (int(round(t * 1000000))) #微秒级时间戳 输出: 1499825149.257892 #原始时间数据 1499825149 #秒级时间戳,10位 1499825149257…
把秒数转换为%d:%02d:%02d 格式 private String stringForTime(int timeSec) { int totalSeconds = timeSec; int seconds = totalSeconds % 60; int minutes = totalSeconds / 60 % 60; int hours = totalSeconds / 3600; if (null!=mFormatBuilder){ this.mFormatBuilder.setLe…
本文转载:http://blog.csdn.net/gaofang2009/article/details/6073231 前天同事问C#有没有相关的方法能把"年月日时分秒"这样的字符串转化为DateTime对象,我之前没碰这样的问题,没处理过,不知道有没有,但想想挺复杂的,例如同样的时间"2010-4-8 12:30:01"就有好几种表示方法: 引用内容 2010040812300120104812301100408123001104812301 可能还有更多,要…
文章来源:https://www.cnblogs.com/hello-tl/p/9263602.html package com.util; import java.text.SimpleDateFormat; import java.util.Date; public class TimeUtil { /** * 获取十三位时间戳 * * @return */ public static String getTimeInt() { String timeInt = String.valueOf…
1.将任意日期格式的字符串转换为指定格式的字符串 //默认格式 String s1 = "20190110133236"; //给定格式 String s2 = "2019-01-10 13:28:15"; 1.首先想到的是利用String中的字符串拆分,然后使用StringBuilder进行字符串拼接.这个方法是代码量最多,也是最笨的方法. StringBuilder builder = new StringBuilder(); String year = act…
下面的SQL文查询结果是 "2018-08-20 10:09:10.815125",并且返回类型可以当String处理.返回json等都方便使用. SQL> SELECT to_char(current_timestamp, 'YYYY-MM-DD HH24:MI:SS'); 更新时,参数传入“2018-08-20 10:09:10.815125”的字符串,那么需要在SQL中转化来匹配updateTime字段的timeStamp数据类型. SQL> update tbl_A…
1.Date转String 将日期格式化成指定的格式 public static String stampToDate(Date date) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); String dateString = simpleDateFormat.format(date); return dateString; } 2.String转Date 注意:String和Date…
字母     日期或时间元素 表示 示例 G Era 标志符 Text AD y 年 Year 1996 ; 96 M 年中的月份 Month July ; Jul ; 07 w 年中的周数 Number 27 W 月份中的周数 Number 2 D 年中的天数 Number 189 d 月份中的天数 Number 10 F 月份中的星期 Number 2 E 星期中的天数 Text Tuesday ; Tue a Am/pm 标记 Text PM H 一天中的小时数(0-23) Number…
格式: [秒] [分] [小时] [日] [月] [周] [年] 通配符说明: \*:表示所有值.例如:在分的字段上设置"\*",表示每一分钟都会触发. ?:表示不指定值.使用的场景为不需要关心当前设置这个字段的值. 例如:要在每月的10号触发一个操作,但不关心是周几,所以需要周位置的那个字段设置为"?具体设置为00010*? -:表示区间.例如在小时上设置"10-12",表示10,11,12点都会触发. ,:表示指定多个值,例如在周字段上设置"…
import datetime print datetime.datetime.now() # 2016-03-28 17:16:00.812000 a = ‘2016-03-28 17:16:00.812000’ timeArray = time.strptime(a, '%Y-%m-%d %H:%M:%S.%f') ##注意: %f是microseconds的格式化符号. print timeArray #time.struct_time(tm_year=2016, tm_mon=3, tm…
关于时间格式转化: java.util.Date 与 java.sql.Date 互换 sql是子类 字符串转化成java.util.Date     SimpleDateFormat date =new SimpleDateFormat("yyyy-MM-dd"); String str="1992-5-6"; Date ud=date.parse(str);   java.util.Date 转化成 java.sql.Date      String str =…
NSdate 时间格式 NSTimeInterval 时间间隔 基本单位 秒 NSDateFormatter 时间格式器 用于日期对象的格式化或字符串解析为日期对象 日期格式如下: y  年 M  年中的月份 D  当天是今年的第多少天 d  月份中的天数 F  月份中的周数 E  星期几 a  Am/pm H  一天中的小时数(0-23) k  一天中的小时数(1-24) K  am/pm 中的小时数(0-11)  Number  0 h  am/pm 中的小时数(1-12)  Number …
一.字符串转化为时间格式 string date = "2018/9/27 10:53:56"; DateTime dt1 = DateTime.Parse(date);//方式1 DateTime dt2 = Convert.ToDateTime(date);//方式2 二.时间格式转化为字符串 DateTime dt = DateTime.Now; string dtstr = dt.ToString(); 三.时间的其它方法 // // 摘要: // 获取当前日期. // //…
1.毫秒值转化为正常时间格式  最简单的方法 new Date(后台传来的毫秒值).toLocaleDateString() 就是这个样子 2.毫秒值转化为自定义的时间格式 本页面重写一下  toLocaleString()方法 Date.prototype.toLocaleString = function() { return this.getFullYear() + "年" + (this.getMonth() + 1) + "月" + this.getDat…
//时间格式转化 getNowDate(timestamp) { var date = new Date(timestamp); //时间戳为10位需*1000,时间戳为13位的话不需乘1000 var Y = date.getFullYear() + '-'; var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'; var D = date.getDate() <…
http://www.chinaitpower.com/A/2005-01-14/104881.html 使用java.util.Calendar返回间隔天数         static int getDaysBetween (java.util.Calendar d1, java.util.Calendar d2) {           if (d1.after(d2)) {  // swap dates so that d1 is start and d2 is end         …
package lianxi; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class date { public static void main(String[] args) { Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat(" yyyy-MM-dd E…
目录 将Date转化为格式化字符串 时间格式字符串转化为Date @ 将Date转化为格式化字符串 将Date转化为格式化字符串是利用SimpleDateFormat类继承自 java.text.DateFormat类的format方法实现的: public final String format(Date date):将日期格式化成日期/时间字符串. //获取当前时间 Date date = new Date(); //定义转化为字符串的日期格式 SimpleDateFormat sdf =…