//判断选择的日期是否是今天
public static boolean isToday(long time) {
return isThisTime(time, "yyyy-MM-dd");
//判断选择的日期是否是本周
public static boolean isThisWeek(long time) {
Calendar calendar = Calendar.getInstance();
int currentWeek = calendar.get(Calendar.WEEK_OF_YEAR);
calendar.setTime(new Date(time));
int paramWeek = calendar.get(Calendar.WEEK_OF_YEAR);
if (paramWeek == currentWeek) {
return true;
return false;
//判断选择的日期是否是本月
public static boolean isThisMonth(long time) {
return isThisTime(time, "yyyy-MM");
public static boolean isThisTime(long time, String pattern) {
Date date = new Date(time);
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
String param = sdf.format(date);//参数时间
String now = sdf.format(new Date());//当前时间
if (param.equals(now)) {
return true;
return false;
@Test
public void testTime() {
isToday(1416360654000L);
isThisMonth(1416360654000L);
isThisWeek(1416360654000L);
public static String getNotifDateStrEnglish(long timeStamp) {
String result = "";
try {
SimpleDateFormat sf1 = new SimpleDateFormat("EEEE,MMMM dd,yyyy h:m");
result = sf1.format(new Date(timeStamp * 1000L));
} catch (Exception e) {
e.printStackTrace();
return result;
public static String getNotifDateStr(long timeStamp) {
String result = "";
try {
SimpleDateFormat sf1 = new SimpleDateFormat("dd/MM/yyyy hh:mm a");
result = sf1.format(new Date(timeStamp * 1000L));
} catch (Exception e) {
e.printStackTrace();
return result;
public static String getNotifDateSms(long timeStamp) {
String result = "";
try {
SimpleDateFormat sf1 = new SimpleDateFormat("hh:mm a");
result = sf1.format(new Date(timeStamp * 1000L));
} catch (Exception e) {
e.printStackTrace();
return result;