文章来源: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. PostgreSQL - 怎么将时间转换成秒

    保留原来的毫秒值 select extract(epoch from '03:21:06.678'::time); 这个extract(epoch from )函数得到的是时间是秒单位,如果需要毫秒值 ...

  2. android 一些常用权限

    <!-- 网络访问权限 --> <uses-permission android:name="android.permission.INTERNET" /> ...

  3. STP-5-STP配置及分析

    拓扑: root id列出了根的网桥id为两部分,前边是优先级,后边跟着mac地址,cost 0 暗示sw1就是根: 下边的命令确认sw1就是vlan1的根: 下边,sw2配置了一个比sw1更低的优先 ...

  4. Info.plist配置相关文件访问权限

    <key>NSAppleMusicUsageDescription</key> <string>App需要您的同意,才能访问媒体资料库</string> ...

  5. [题解](区间质数筛)POJ_2689 Prime Distance

    区间筛素数:先筛出1~sqrt(R)的素数,然后对于每个询问只要用这些素数筛掉区间内的合数即可. 几个细节:1.特判和1有关的一些情况 2.每次减去L偏移量,数组只开区间大小 3.POJ无法使用万能头 ...

  6. 【bzoj3033】太鼓达人

    3033: 太鼓达人 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 521  Solved: 399[Submit][Status][Discuss] ...

  7. websocket~~原理详细解说优秀文(转)

    新项目有个实时刷新新消息的功能,具体的有实时更新别人的回复,实时推送验证请求等功能, 在网上发现了关于websocket的优秀文,地址: https://marvelapp.com/1759hgb6/ ...

  8. 089 Gray Code 格雷编码

    格雷编码是一个二进制数字系统,在该系统中,两个连续的数值仅有一个位数的差异.给定一个代表编码总位数的非负整数 n,打印格雷码序列.格雷码序列必须以0开头.例如, 给定 n = 2, 返回 [0,1,3 ...

  9. csu 1551: Longest Increasing Subsequence Again BIT + 思维

    预处理last[i]表示以第i个开始,的合法后缀. pre[i]表示以第i个结尾,的合法前缀. 那么每一个数a[i],肯定是一个合法后缀last[i] + 一个合法前缀,那么合法前缀的数字要小于a[i ...

  10. WGET and CURL

    目录 WGET and CURL 对比 wget curl curl使用示例 WGET and CURL 对比 CURL 和WGET都可以用来下载文件,用法也类似:curl/wget [-option ...