文章来源: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(System.currentTimeMillis());
return timeInt;
} /**
* 获取 data Time 格式时间
*
* @return
*/
public static String getDataTime() {
Date day = new Date();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return df.format(day);
} /**
* 日期格式字符串转换成时间戳
*
* @param format 如:yyyy-MM-dd HH:mm:ss
* @return
*/
public static String date2TimeStamp(String date_str, String format) {
try {
SimpleDateFormat sdf = new SimpleDateFormat(format);
return String.valueOf(sdf.parse(date_str).getTime());
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
}

文章来源:https://www.cnblogs.com/hello-tl/p/9263602.html

java获取时间格式的更多相关文章

  1. java获取时间

    string startTimeStr = ((String) jsonCampaign.get(configObj.getKeyword(config.START_TIME)));          ...

  2. Java获取时间,将当前时间减一年,减一天,减一个月

    在Java中操作时间的时候,需要计算某段时间开始到结束的区间日期,常用的时间工具 Date date = new Date();//获取当前时间 Calendar calendar = Calenda ...

  3. JAVA获取时间的方式

      1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 ...

  4. Java中时间格式处理,指定N天/小时等之后的时间

    1)根据当前时间,获取具体的时刻的时间 N天前 M小时之前 可用 new Date().getTime() - 24 * 60 * 60 * 1000*N[N天之前]的方法来获取处理时间之后的具体的值 ...

  5. java格式化时间格式

    System.out.println("Hello World!"); SimpleDateFormat format = new SimpleDateFormat( " ...

  6. java校验时间格式 HH:MM

    package com; import java.text.SimpleDateFormat; import java.util.Date; /** * @author Gerrard */ publ ...

  7. JAVA中时间格式(SimpleDateFormat)和数字格式(DecimalFormat)转换详解(转)

    时间格式转换SimpleDateFormat: //定义日期的格式 SimpleDateFormat format =new SimpleDateFormat("yyMMdd"); ...

  8. Java获取时间与系统时间相差8小时终极解决方案

    一.在取日期以前设置一下时区 TimeZone tz = TimeZone.getTimeZone(“ETC/GMT-8″);TimeZone.setDefault(tz); 此种方法适用于单次快速获 ...

  9. sql server获取时间格式

    在本文中,GetDate()获得的日期由两部分组成,分别是今天的日期和当时的时间: Select GetDate()  用DateName()就可以获得相应的年.月.日,然后再把它们连接起来就可以了: ...

随机推荐

  1. Java - Class版本号和UnsupportedClassVersionError

    问题分析 Java是向下兼容的,每一个jdk版本都有对应的class版本号(major + minor version numbers):如果用低版本的jvm去加载高版本jdk编译的类,就会报错:ja ...

  2. go系列(4)- go环境和docker容器的使用

    这篇文章讲述把go环境及beego框架装进容器.docker的安装该篇不讲述,请自行查阅.本篇是基于docker已经安装的前提. 跟据前三篇系列,然后写Dockerfile,一般是到项目的根目录下 1 ...

  3. PostgreSQL-6-数据分组

    基本语法 SELECT column-list FROM table_name WHERE [ conditions ] GROUP BY column1, column2 HAVING [ cond ...

  4. 根据日期计算发布时间段(NSCalendar)

    // 返回发布时间dateWithString - (NSString *)backReleaseTimeWithDateStr:(NSString *)dateWithString{ // 获取当前 ...

  5. 转 错误:ORA-28002/ORA-65162 : the password will expire within 7 days 解决方法

    今天在使用sqlplus时出现 =============================================== ERROR:ORA-28002: the password will e ...

  6. 【转】HashMap,ArrayMap,SparseArray源码分析及性能对比

    HashMap,ArrayMap,SparseArray源码分析及性能对比 jjlanbupt 关注 2016.06.03 20:19* 字数 2165 阅读 7967评论 13喜欢 43 Array ...

  7. drupal6提示 Compilation failed: disallowed Unicode code point (>= 0xd800 && <= 0xdfff) at offset 9 on line 615

    解决办法:将sites\all\modules\ctools\includes\cleanstring.inc文件中的61行改成62行这样子即可,如下图

  8. Does Little'law really applicable to apply performance model now?

    上次提到Little定律, 我也解释过它跟另外一个公式有一些内在的关系,但是其实我自己对LL在当前复杂架构系统中到底是怎么应用的也没有完整的想法,于是我在Linkedin上把这个问题抛了出来,没有想到 ...

  9. Idea注释参数报错,控制台乱码问题解决方法

    idea虽然工具非常好用,但是他的一些解决方法网上非常的少,有些压根没有,解决这些问题非常浪费时间 1.最近在工作中发现一个问题,使用ant打包后,控制台总是报错,提示信息还是乱码的,吓得我赶紧用回了 ...

  10. JavaScript数据格式验证探讨

    1.需求 修改某个文本框数据,要求对修改后的格式做验证(必须是数字). 注:实际需求比上述复杂,为了说明问题,这里特意简化了需求(如:对修改后数据依赖条件的判断,数据入库等). 2.关于NaN的探讨( ...