|
|
@@ -10,18 +10,12 @@ import java.util.Date;
|
|
|
|
|
|
/**
|
|
|
* @author myLove
|
|
|
- * @time 2017/11/15 10:15
|
|
|
- * @e-mail mylove.520.y@gmail.com
|
|
|
- * @overview
|
|
|
*/
|
|
|
|
|
|
public class DateUtil {
|
|
|
/**
|
|
|
* 时间戳转换成日期格式字符串
|
|
|
- *
|
|
|
- * @param seconds 精确到秒的字符串
|
|
|
- * @param
|
|
|
- * @return
|
|
|
+ * seconds 精确到秒的字符串
|
|
|
*/
|
|
|
public static String timeStamp2Date(String seconds, String format) {
|
|
|
if (seconds == null || seconds.isEmpty() || seconds.equals("null")) {
|
|
|
@@ -35,9 +29,6 @@ public class DateUtil {
|
|
|
|
|
|
/**
|
|
|
* 计算两个日期型的时间相差多少时间
|
|
|
- *
|
|
|
- * @param
|
|
|
- * @return
|
|
|
*/
|
|
|
@SuppressLint("SimpleDateFormat")
|
|
|
public static String twoDateDistance(String endDates) {
|
|
|
@@ -107,7 +98,6 @@ public class DateUtil {
|
|
|
* 时间戳转换成日期格式字符串
|
|
|
*
|
|
|
* @param seconds 精确到秒的字符串
|
|
|
- * @return
|
|
|
*/
|
|
|
public static String timeStamp2Date(String seconds) {
|
|
|
if (seconds == null || seconds.isEmpty() || seconds.equals("null")) {
|
|
|
@@ -121,9 +111,7 @@ public class DateUtil {
|
|
|
/**
|
|
|
* 日期格式字符串转换成时间戳
|
|
|
*
|
|
|
- * @param
|
|
|
* @param format 如:yyyy-MM-dd HH:mm:ss
|
|
|
- * @return
|
|
|
*/
|
|
|
public static String date2TimeStamp(String date_str, String format) {
|
|
|
// 2016-03-13 03:29:00
|
|
|
@@ -138,8 +126,6 @@ public class DateUtil {
|
|
|
|
|
|
/**
|
|
|
* 取得当前时间戳(精确到秒)
|
|
|
- *
|
|
|
- * @return
|
|
|
*/
|
|
|
public static String timeStamp() {
|
|
|
long time = System.currentTimeMillis();
|
|
|
@@ -161,9 +147,6 @@ public class DateUtil {
|
|
|
|
|
|
/**
|
|
|
* 得到当前的时间
|
|
|
- *
|
|
|
- * @param format
|
|
|
- * @return
|
|
|
*/
|
|
|
public static String getStringDate(String format) {
|
|
|
Date currentTime = new Date();
|
|
|
@@ -174,11 +157,6 @@ public class DateUtil {
|
|
|
|
|
|
/**
|
|
|
* 计算时间差
|
|
|
- *
|
|
|
- * @param startTime
|
|
|
- * @param endTime
|
|
|
- * @param format
|
|
|
- * @return
|
|
|
*/
|
|
|
public static String TimeDifference(String startTime, String endTime, String format) {
|
|
|
String str = "";
|
|
|
@@ -213,10 +191,6 @@ public class DateUtil {
|
|
|
|
|
|
/**
|
|
|
* 计算时间差
|
|
|
- *
|
|
|
- * @param startTime
|
|
|
- * @param endTime
|
|
|
- * @return
|
|
|
*/
|
|
|
public static String TimeDifference(String startTime, String endTime) {
|
|
|
String str = "剩余";
|
|
|
@@ -326,8 +300,6 @@ public class DateUtil {
|
|
|
|
|
|
/**
|
|
|
* 获取时间 小时:分;秒 HH:mm:ss
|
|
|
- *
|
|
|
- * @return
|
|
|
*/
|
|
|
public static String getTimeShort() {
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
|
|
|
@@ -338,9 +310,6 @@ public class DateUtil {
|
|
|
|
|
|
/**
|
|
|
* 将长时间格式字符串转换为时间 yyyy-MM-dd HH:mm:ss
|
|
|
- *
|
|
|
- * @param strDate
|
|
|
- * @return
|
|
|
*/
|
|
|
public static Date strToDateLong(String strDate) {
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
@@ -351,9 +320,6 @@ public class DateUtil {
|
|
|
|
|
|
/**
|
|
|
* 将长时间格式时间转换为字符串 yyyy-MM-dd HH:mm:ss
|
|
|
- *
|
|
|
- * @param dateDate
|
|
|
- * @return
|
|
|
*/
|
|
|
public static String dateToStrLong(Date dateDate) {
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
@@ -363,10 +329,6 @@ public class DateUtil {
|
|
|
|
|
|
/**
|
|
|
* 将短时间格式时间转换为字符串 yyyy-MM-dd
|
|
|
- *
|
|
|
- * @param dateDate
|
|
|
- * @param
|
|
|
- * @return
|
|
|
*/
|
|
|
public static String dateToStr(Date dateDate) {
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
@@ -376,9 +338,6 @@ public class DateUtil {
|
|
|
|
|
|
/**
|
|
|
* 将短时间格式字符串转换为时间 yyyy-MM-dd
|
|
|
- *
|
|
|
- * @param strDate
|
|
|
- * @return
|
|
|
*/
|
|
|
public static Date strToDate(String strDate) {
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
@@ -389,8 +348,6 @@ public class DateUtil {
|
|
|
|
|
|
/**
|
|
|
* 得到现在时间
|
|
|
- *
|
|
|
- * @return
|
|
|
*/
|
|
|
public static Date getNow() {
|
|
|
Date currentTime = new Date();
|
|
|
@@ -399,9 +356,6 @@ public class DateUtil {
|
|
|
|
|
|
/**
|
|
|
* 提取一个月中的最后一天
|
|
|
- *
|
|
|
- * @param day
|
|
|
- * @return
|
|
|
*/
|
|
|
public static Date getLastDate(long day) {
|
|
|
Date date = new Date();
|
|
|
@@ -436,8 +390,6 @@ public class DateUtil {
|
|
|
|
|
|
/**
|
|
|
* 得到现在分钟
|
|
|
- *
|
|
|
- * @return
|
|
|
*/
|
|
|
public static String getTime() {
|
|
|
Date currentTime = new Date();
|
|
|
@@ -450,9 +402,6 @@ public class DateUtil {
|
|
|
|
|
|
/**
|
|
|
* 根据用户传入的时间表示格式,返回当前时间的格式 如果是yyyyMMdd,注意字母y不能大写。
|
|
|
- *
|
|
|
- * @param sformat yyyyMMddhhmmss
|
|
|
- * @return
|
|
|
*/
|
|
|
public static String getUserDate(String sformat) {
|
|
|
Date currentTime = new Date();
|
|
|
@@ -464,7 +413,6 @@ public class DateUtil {
|
|
|
/**
|
|
|
* @param strDate 当前时间
|
|
|
* @param pattern 时间格式
|
|
|
- * @return
|
|
|
*/
|
|
|
public static Date strToDate(String strDate, String pattern) {
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat(pattern);
|
|
|
@@ -476,7 +424,6 @@ public class DateUtil {
|
|
|
/**
|
|
|
* @param strDate 时间
|
|
|
* @param pattern 时间格式
|
|
|
- * @return
|
|
|
*/
|
|
|
public static String getDate(String strDate, String pattern) {
|
|
|
Date currentTime = strToDate(strDate, pattern);
|
|
|
@@ -487,8 +434,6 @@ public class DateUtil {
|
|
|
|
|
|
/**
|
|
|
* 判断星期几
|
|
|
- * @param date
|
|
|
- * @return
|
|
|
*/
|
|
|
public static String getWeek(String date) {
|
|
|
String week = "";
|