Android(java)时间转换星期 昨天 今天 几分钟前工具
2017-07-01 12:27
555 查看
摘要来自:http://blog.csdn.net/syif88/article/details/53517613
显示样例如下:
![](https://oscdn.geek-share.com/Uploads/Images/Content/201707/ade2b3b3ebeafb7344c81d3e50b63b73)
![](https://oscdn.geek-share.com/Uploads/Images/Content/201707/10e6423c7f921693f56657cfcfa974bc)
代码如下:package utils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class TimeUtil {
static SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
/**
* 24小时制转化成12小时制
*
* @param strDay
*/
public static String timeFormatStr(Calendar calendar, String strDay) {
String tempStr = "";
int hour = calendar.get(Calendar.HOUR_OF_DAY);
if (hour > 11) {
tempStr = "下午" + " " + strDay;
} else {
tempStr = "上午" + " " + strDay;
}
return tempStr;
}
/**
* 时间转化为星期
*
* @param indexOfWeek
* 星期的第几天
*/
public static String getWeekDayStr(int indexOfWeek) {
String weekDayStr = "";
switch (indexOfWeek) {
case 1:
weekDayStr = "星期日";
break;
case 2:
weekDayStr = "星期一";
break;
case 3:
weekDayStr = "星期二";
break;
case 4:
weekDayStr = "星期三";
break;
case 5:
weekDayStr = "星期四";
break;
case 6:
weekDayStr = "星期五";
break;
case 7:
weekDayStr = "星期六";
break;
}
return weekDayStr;
}
/**
* 将时间戳格式化,13位的转为10位
*
* @param timestamp
* @return
*/
public static long timestampFormate(long timestamp) {
String timestampStr = timestamp + "";
if (timestampStr.length() == 13) {
timestamp = timestamp / 1000;
}
return timestamp;
}
/**
* 获取日起时间秒差
*
* @param time
* 需要格式化的时间 如"2014-07-14 19:01:45"
* @param pattern
* 输入参数time的时间格式 如:"yyyy-MM-dd HH:mm:ss"
* <p/>
* 如果为空则默认使用"yyyy-MM-dd HH:mm:ss"格式
* @return time为null,或者时间格式不匹配,输出空字符""
* @throws ParseException
*/
public static long formatLongTime(String time, String pattern) {
long dTime = 0;
if (time != null) {
if (pattern == null)
pattern = "yyyy-MM-dd HH:mm:ss";
Date tDate;
try {
tDate = new SimpleDateFormat(pattern).parse(time);
Date today = new Date();
if (tDate != null) {
dTime = (today.getTime() - tDate.getTime()) / 1000;
}
} catch (ParseException e) {
e.printStackTrace();
}
}
return dTime;
}
/**
* 获取日期时间戳
*
* @param time
* 需要格式化的时间 如"2014-07-14 19:01:45"
* @param pattern
* 输入参数time的时间格式 如:"yyyy-MM-dd HH:mm:ss"
* <p/>
* 如果为空则默认使用"yyyy-MM-dd HH:mm:ss"格式
* @return time为null,或者时间格式不匹配,输出空字符""
* @throws ParseException
*/
public static long timeStamp(String time, String pattern) {
long dTime = 0;
if (time != null) {
if (pattern == null)
pattern = "yyyy-MM-dd HH:mm:ss";
Date tDate;
try {
tDate = new SimpleDateFormat(pattern).parse(time);
if (tDate != null) {
dTime = tDate.getTime() / 1000;
}
} catch (ParseException e) {
e.printStackTrace();
}
}
return dTime;
}
/**
* 时间转化为显示字符串
*
* @param timeStamp
* 单位为秒
*/
public static String getTimeStr(long timeStamp) {
if (timeStamp == 0)
return "";
Calendar inputTime = Calendar.getInstance();
inputTime.setTimeInMillis(timeStamp * 1000);
Date currenTimeZone = inputTime.getTime();
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 23);
calendar.set(Calendar.MINUTE, 59);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
if (calendar.before(inputTime)) {
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
return sdf.format(currenTimeZone);
}
calendar.add(Calendar.DAY_OF_MONTH, -1);
if (calendar.before(inputTime)) {
return "昨天";
} else {
calendar.add(Calendar.DAY_OF_MONTH, -5);
if (calendar.before(inputTime)) {
return getWeekDayStr(inputTime.get(Calendar.DAY_OF_WEEK));
} else {
calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.set(Calendar.MONTH, Calendar.JANUARY);
int year = inputTime.get(Calendar.YEAR);
int month = inputTime.get(Calendar.MONTH);
int day = inputTime.get(Calendar.DAY_OF_MONTH);
return year + "/" + month + "/" + day;
}
}
}
/**
* 时间转化为聊天界面显示字符串
*
* @param timeStamp
* 单位为秒
*/
public static String getChatTimeStr(long timeStamp) {
if (timeStamp == 0)
return "";
Calendar inputTime = Calendar.getInstance();
String timeStr = timeStamp + "";
if (timeStr.length() == 10) {
timeStamp = timeStamp * 1000;
}
inputTime.setTimeInMillis(timeStamp);
Date currenTimeZone = inputTime.getTime();
Calendar calendar = Calendar.getInstance();
// if (calendar.before(inputTime)){
// //当前时间在输入时间之前
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy" +
// "年"+"MM"+"月"+"dd"+"日");
// return sdf.format(currenTimeZone);
// }
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
if (calendar.before(inputTime)) {
SimpleDateFormat sdf = new SimpleDateFormat("h:mm");
return timeFormatStr(inputTime, sdf.format(currenTimeZone));
}
calendar.add(Calendar.DAY_OF_MONTH, -1);
if (calendar.before(inputTime)) {
SimpleDateFormat sdf = new SimpleDateFormat("h:mm");
return "昨天" + " " + timeFormatStr(inputTime, sdf.format(currenTimeZone));
} else {
calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.set(Calendar.MONTH, Calendar.JANUARY);
if (calendar.before(inputTime)) {
SimpleDateFormat sdf = new SimpleDateFormat("M" + "月" + "d" + "日");
String temp1 = sdf.format(currenTimeZone);
SimpleDateFormat sdf1 = new SimpleDateFormat("h:mm");
String temp2 = timeFormatStr(inputTime, sdf1.format(currenTimeZone));
return temp1 + temp2;
} else {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy" + "/" + "M" + "/" + "d" + " ");
String temp1 = sdf.format(currenTimeZone);
SimpleDateFormat sdf1 = new SimpleDateFormat("h:mm");
String temp2 = timeFormatStr(inputTime, sdf1.format(currenTimeZone));
return temp1 + temp2;
}
}
}
/**
* 群发使用的时间转换
*/
public static String multiSendTimeToStr(long timeStamp) {
if (timeStamp == 0)
return "";
Calendar inputTime = Calendar.getInstance();
String timeStr = timeStamp + "";
if (timeStr.length() == 10) {
timeStamp = timeStamp * 1000;
}
inputTime.setTimeInMillis(timeStamp);
Date currenTimeZone = inputTime.getTime();
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
if (calendar.before(inputTime)) {
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
return sdf.format(currenTimeZone);
}
calendar.add(Calendar.DAY_OF_MONTH, -1);
if (calendar.before(inputTime)) {
4000
@SuppressWarnings("unused")
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
return "昨天";
} else {
calendar.add(Calendar.DAY_OF_MONTH, -5);
if (calendar.before(inputTime)) {
return getWeekDayStr(inputTime.get(Calendar.DAY_OF_WEEK));
} else {
calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.set(Calendar.MONTH, Calendar.JANUARY);
if (calendar.before(inputTime)) {
SimpleDateFormat sdf = new SimpleDateFormat("M" + "/" + "d" + " ");
String temp1 = sdf.format(currenTimeZone);
SimpleDateFormat sdf1 = new SimpleDateFormat("HH:mm");
String temp2 = sdf1.format(currenTimeZone);
return temp1 + temp2;
} else {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy" + "/" + "M" + "/" + "d" + " ");
String temp1 = sdf.format(currenTimeZone);
SimpleDateFormat sdf1 = new SimpleDateFormat("HH:mm");
String temp2 = sdf1.format(currenTimeZone);
return temp1 + temp2;
}
}
}
}
/**
* 格式化时间(输出类似于 刚刚, 4分钟前, 一小时前, 昨天这样的时间)
*
* @param time
* 需要格式化的时间 如"2014-07-14 19:01:45"
* @param pattern
* 输入参数time的时间格式 如:"yyyy-MM-dd HH:mm:ss"
* <p/>
* 如果为空则默认使用"yyyy-MM-dd HH:mm:ss"格式
* @return time为null,或者时间格式不匹配,输出空字符""
*/
public static String formatDisplayTime(String time, String pattern) {
String display = "";
int tMin = 60 * 1000;
int tHour = 60 * tMin;
int tDay = 24 * tHour;
if (time != null) {
if (pattern == null)
pattern = "yyyy-MM-dd HH:mm:ss";
try {
Date tDate = new SimpleDateFormat(pattern).parse(time);
Date today = new Date();
SimpleDateFormat thisYearDf = new SimpleDateFormat("yyyy");
SimpleDateFormat todayDf = new SimpleDateFormat("yyyy-MM-dd");
Date thisYear = new Date(thisYearDf.parse(thisYearDf.format(today)).getTime());
Date yesterday = new Date(todayDf.parse(todayDf.format(today)).getTime());
Date beforeYes = new Date(yesterday.getTime() - tDay);
if (tDate != null) {
@SuppressWarnings("unused")
SimpleDateFormat halfDf = new SimpleDateFormat("MM月dd日");
long dTime = today.getTime() - tDate.getTime();
if (tDate.before(thisYear)) {
display = new SimpleDateFormat("yyyy年MM月dd日").format(tDate);
} else {
if (dTime < tMin) {
display = "刚刚";
} else if (dTime < tHour) {
display = (int) Math.ceil(dTime / tMin) + "分钟前";
} else if (dTime < tDay && tDate.after(yesterday)) {
display = (int) Math.ceil(dTime / tHour) + "小时前";
} else if (tDate.after(beforeYes) && tDate.before(yesterday)) {
display = "昨天 " + new SimpleDateFormat("HH:mm").format(tDate);
} else {
display = multiSendTimeToStr(tDate.getTime() / 1000);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
return display;
}
public static void main(String[] args) {
//TODO 当前时间
System.out.println(sf.format(new Date()));
// TODO 字传入时间日期字符串转换群发使用时间输出
System.out.println(formatDisplayTime("2017-06-30 10:34:00", null));
// TODO 先 转换成时间戳 转换成对应的时间输出格式
long timeStamp = timeStamp("2017-06-29 10:34:00", null);
System.out.println(multiSendTimeToStr(timeStamp));//群发使用时间
System.out.println(getChatTimeStr(timeStamp));//时间转化为聊天界面显示字符串
System.out.println(getTimeStr(timeStamp));//时间转化为显示字符串
}
}
显示样例如下:
代码如下:package utils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class TimeUtil {
static SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
/**
* 24小时制转化成12小时制
*
* @param strDay
*/
public static String timeFormatStr(Calendar calendar, String strDay) {
String tempStr = "";
int hour = calendar.get(Calendar.HOUR_OF_DAY);
if (hour > 11) {
tempStr = "下午" + " " + strDay;
} else {
tempStr = "上午" + " " + strDay;
}
return tempStr;
}
/**
* 时间转化为星期
*
* @param indexOfWeek
* 星期的第几天
*/
public static String getWeekDayStr(int indexOfWeek) {
String weekDayStr = "";
switch (indexOfWeek) {
case 1:
weekDayStr = "星期日";
break;
case 2:
weekDayStr = "星期一";
break;
case 3:
weekDayStr = "星期二";
break;
case 4:
weekDayStr = "星期三";
break;
case 5:
weekDayStr = "星期四";
break;
case 6:
weekDayStr = "星期五";
break;
case 7:
weekDayStr = "星期六";
break;
}
return weekDayStr;
}
/**
* 将时间戳格式化,13位的转为10位
*
* @param timestamp
* @return
*/
public static long timestampFormate(long timestamp) {
String timestampStr = timestamp + "";
if (timestampStr.length() == 13) {
timestamp = timestamp / 1000;
}
return timestamp;
}
/**
* 获取日起时间秒差
*
* @param time
* 需要格式化的时间 如"2014-07-14 19:01:45"
* @param pattern
* 输入参数time的时间格式 如:"yyyy-MM-dd HH:mm:ss"
* <p/>
* 如果为空则默认使用"yyyy-MM-dd HH:mm:ss"格式
* @return time为null,或者时间格式不匹配,输出空字符""
* @throws ParseException
*/
public static long formatLongTime(String time, String pattern) {
long dTime = 0;
if (time != null) {
if (pattern == null)
pattern = "yyyy-MM-dd HH:mm:ss";
Date tDate;
try {
tDate = new SimpleDateFormat(pattern).parse(time);
Date today = new Date();
if (tDate != null) {
dTime = (today.getTime() - tDate.getTime()) / 1000;
}
} catch (ParseException e) {
e.printStackTrace();
}
}
return dTime;
}
/**
* 获取日期时间戳
*
* @param time
* 需要格式化的时间 如"2014-07-14 19:01:45"
* @param pattern
* 输入参数time的时间格式 如:"yyyy-MM-dd HH:mm:ss"
* <p/>
* 如果为空则默认使用"yyyy-MM-dd HH:mm:ss"格式
* @return time为null,或者时间格式不匹配,输出空字符""
* @throws ParseException
*/
public static long timeStamp(String time, String pattern) {
long dTime = 0;
if (time != null) {
if (pattern == null)
pattern = "yyyy-MM-dd HH:mm:ss";
Date tDate;
try {
tDate = new SimpleDateFormat(pattern).parse(time);
if (tDate != null) {
dTime = tDate.getTime() / 1000;
}
} catch (ParseException e) {
e.printStackTrace();
}
}
return dTime;
}
/**
* 时间转化为显示字符串
*
* @param timeStamp
* 单位为秒
*/
public static String getTimeStr(long timeStamp) {
if (timeStamp == 0)
return "";
Calendar inputTime = Calendar.getInstance();
inputTime.setTimeInMillis(timeStamp * 1000);
Date currenTimeZone = inputTime.getTime();
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 23);
calendar.set(Calendar.MINUTE, 59);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
if (calendar.before(inputTime)) {
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
return sdf.format(currenTimeZone);
}
calendar.add(Calendar.DAY_OF_MONTH, -1);
if (calendar.before(inputTime)) {
return "昨天";
} else {
calendar.add(Calendar.DAY_OF_MONTH, -5);
if (calendar.before(inputTime)) {
return getWeekDayStr(inputTime.get(Calendar.DAY_OF_WEEK));
} else {
calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.set(Calendar.MONTH, Calendar.JANUARY);
int year = inputTime.get(Calendar.YEAR);
int month = inputTime.get(Calendar.MONTH);
int day = inputTime.get(Calendar.DAY_OF_MONTH);
return year + "/" + month + "/" + day;
}
}
}
/**
* 时间转化为聊天界面显示字符串
*
* @param timeStamp
* 单位为秒
*/
public static String getChatTimeStr(long timeStamp) {
if (timeStamp == 0)
return "";
Calendar inputTime = Calendar.getInstance();
String timeStr = timeStamp + "";
if (timeStr.length() == 10) {
timeStamp = timeStamp * 1000;
}
inputTime.setTimeInMillis(timeStamp);
Date currenTimeZone = inputTime.getTime();
Calendar calendar = Calendar.getInstance();
// if (calendar.before(inputTime)){
// //当前时间在输入时间之前
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy" +
// "年"+"MM"+"月"+"dd"+"日");
// return sdf.format(currenTimeZone);
// }
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
if (calendar.before(inputTime)) {
SimpleDateFormat sdf = new SimpleDateFormat("h:mm");
return timeFormatStr(inputTime, sdf.format(currenTimeZone));
}
calendar.add(Calendar.DAY_OF_MONTH, -1);
if (calendar.before(inputTime)) {
SimpleDateFormat sdf = new SimpleDateFormat("h:mm");
return "昨天" + " " + timeFormatStr(inputTime, sdf.format(currenTimeZone));
} else {
calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.set(Calendar.MONTH, Calendar.JANUARY);
if (calendar.before(inputTime)) {
SimpleDateFormat sdf = new SimpleDateFormat("M" + "月" + "d" + "日");
String temp1 = sdf.format(currenTimeZone);
SimpleDateFormat sdf1 = new SimpleDateFormat("h:mm");
String temp2 = timeFormatStr(inputTime, sdf1.format(currenTimeZone));
return temp1 + temp2;
} else {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy" + "/" + "M" + "/" + "d" + " ");
String temp1 = sdf.format(currenTimeZone);
SimpleDateFormat sdf1 = new SimpleDateFormat("h:mm");
String temp2 = timeFormatStr(inputTime, sdf1.format(currenTimeZone));
return temp1 + temp2;
}
}
}
/**
* 群发使用的时间转换
*/
public static String multiSendTimeToStr(long timeStamp) {
if (timeStamp == 0)
return "";
Calendar inputTime = Calendar.getInstance();
String timeStr = timeStamp + "";
if (timeStr.length() == 10) {
timeStamp = timeStamp * 1000;
}
inputTime.setTimeInMillis(timeStamp);
Date currenTimeZone = inputTime.getTime();
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
if (calendar.before(inputTime)) {
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
return sdf.format(currenTimeZone);
}
calendar.add(Calendar.DAY_OF_MONTH, -1);
if (calendar.before(inputTime)) {
4000
@SuppressWarnings("unused")
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
return "昨天";
} else {
calendar.add(Calendar.DAY_OF_MONTH, -5);
if (calendar.before(inputTime)) {
return getWeekDayStr(inputTime.get(Calendar.DAY_OF_WEEK));
} else {
calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.set(Calendar.MONTH, Calendar.JANUARY);
if (calendar.before(inputTime)) {
SimpleDateFormat sdf = new SimpleDateFormat("M" + "/" + "d" + " ");
String temp1 = sdf.format(currenTimeZone);
SimpleDateFormat sdf1 = new SimpleDateFormat("HH:mm");
String temp2 = sdf1.format(currenTimeZone);
return temp1 + temp2;
} else {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy" + "/" + "M" + "/" + "d" + " ");
String temp1 = sdf.format(currenTimeZone);
SimpleDateFormat sdf1 = new SimpleDateFormat("HH:mm");
String temp2 = sdf1.format(currenTimeZone);
return temp1 + temp2;
}
}
}
}
/**
* 格式化时间(输出类似于 刚刚, 4分钟前, 一小时前, 昨天这样的时间)
*
* @param time
* 需要格式化的时间 如"2014-07-14 19:01:45"
* @param pattern
* 输入参数time的时间格式 如:"yyyy-MM-dd HH:mm:ss"
* <p/>
* 如果为空则默认使用"yyyy-MM-dd HH:mm:ss"格式
* @return time为null,或者时间格式不匹配,输出空字符""
*/
public static String formatDisplayTime(String time, String pattern) {
String display = "";
int tMin = 60 * 1000;
int tHour = 60 * tMin;
int tDay = 24 * tHour;
if (time != null) {
if (pattern == null)
pattern = "yyyy-MM-dd HH:mm:ss";
try {
Date tDate = new SimpleDateFormat(pattern).parse(time);
Date today = new Date();
SimpleDateFormat thisYearDf = new SimpleDateFormat("yyyy");
SimpleDateFormat todayDf = new SimpleDateFormat("yyyy-MM-dd");
Date thisYear = new Date(thisYearDf.parse(thisYearDf.format(today)).getTime());
Date yesterday = new Date(todayDf.parse(todayDf.format(today)).getTime());
Date beforeYes = new Date(yesterday.getTime() - tDay);
if (tDate != null) {
@SuppressWarnings("unused")
SimpleDateFormat halfDf = new SimpleDateFormat("MM月dd日");
long dTime = today.getTime() - tDate.getTime();
if (tDate.before(thisYear)) {
display = new SimpleDateFormat("yyyy年MM月dd日").format(tDate);
} else {
if (dTime < tMin) {
display = "刚刚";
} else if (dTime < tHour) {
display = (int) Math.ceil(dTime / tMin) + "分钟前";
} else if (dTime < tDay && tDate.after(yesterday)) {
display = (int) Math.ceil(dTime / tHour) + "小时前";
} else if (tDate.after(beforeYes) && tDate.before(yesterday)) {
display = "昨天 " + new SimpleDateFormat("HH:mm").format(tDate);
} else {
display = multiSendTimeToStr(tDate.getTime() / 1000);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
return display;
}
public static void main(String[] args) {
//TODO 当前时间
System.out.println(sf.format(new Date()));
// TODO 字传入时间日期字符串转换群发使用时间输出
System.out.println(formatDisplayTime("2017-06-30 10:34:00", null));
// TODO 先 转换成时间戳 转换成对应的时间输出格式
long timeStamp = timeStamp("2017-06-29 10:34:00", null);
System.out.println(multiSendTimeToStr(timeStamp));//群发使用时间
System.out.println(getChatTimeStr(timeStamp));//时间转化为聊天界面显示字符串
System.out.println(getTimeStr(timeStamp));//时间转化为显示字符串
}
}
相关文章推荐
- Android时间转换星期 昨天 今天工具
- Android/JAVA 针对时间戳转今天昨天前天,以及刚刚,几分钟的显示
- Android 字符串转指定格式时间 日期处理 去掉月份或天多余的0 获取今天 昨天 明天等的日期和星期
- Android & Java DateUtils 拿来就用 包含常用的日期和时间转换的工具
- Java写的获取日期工具类(今天、昨天、本周、上周、本月、上月、本年及特定时间的开始时间和结束时间)
- android 时间戳转换和dptopx转换工具(java)
- java判断时点所在时间(昨天,今天,前天)
- Java 、Android 时间,日历,日期转换
- php根据时间显示刚刚,几分钟前,今天,昨天的实现代码
- 一个Android JAVA代码中的各显示单位转换工具
- 使用javascript将时间转换成今天,昨天,前天等格式
- [Java]对时间进行格式化:昨天、今天、明天、星期几
- Android 开发工具类,常用方法,Log 工具,数据库,时间戳转换
- Java时间戳转化为今天、昨天、明天(字符串格式)
- Android工具之把int类型整数毫秒值转换为时间分秒格式
- Android 判断获取的时间是否是今天、昨天
- scala时间处理-获取今天日期,昨天日期,本周时间,本月时间,时间戳转换日期,时间比较
- java时间自动转成今天、昨天、前天,如果是同一年刚显示月日,不同年的把年也显示
- 使用javascript将时间转换成今天,昨天,前天等格式
- Java时间戳转化为今天、昨天、明天(字符串格式)