bugfixes:修复闹钟修改默认值,联系人为空时不显示占用,屏幕旋转会错乱,整点报时会息屏亮屏多次播报 update:主页不显示地址,微信拨号优化,优化离线联系人
42 lines
1.2 KiB
Java
42 lines
1.2 KiB
Java
package com.vscool.os.utils;
|
|
|
|
import java.util.Calendar;
|
|
import java.util.Date;
|
|
|
|
public class DayUtils {
|
|
public static boolean isNight() {
|
|
Calendar calendar = Calendar.getInstance();
|
|
int hour = calendar.get(Calendar.HOUR_OF_DAY);
|
|
int minute = calendar.get(Calendar.MINUTE);
|
|
int second = calendar.get(Calendar.SECOND);
|
|
return hour >= 16 && minute >= 30;
|
|
}
|
|
|
|
private static final String[] WEEKS = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
|
|
|
|
|
|
/**
|
|
* @return 根据日期取得星期几
|
|
*/
|
|
public static String getWeek(Date date) {
|
|
Calendar cal = Calendar.getInstance();
|
|
cal.setTime(date);
|
|
int weekIndex = cal.get(Calendar.DAY_OF_WEEK) - 1;
|
|
if (weekIndex < 0) {
|
|
weekIndex = 0;
|
|
}
|
|
return WEEKS[weekIndex];
|
|
}
|
|
|
|
public static String getWeek() {
|
|
Date date = new Date();
|
|
Calendar cal = Calendar.getInstance();
|
|
cal.setTime(date);
|
|
int weekIndex = cal.get(Calendar.DAY_OF_WEEK) - 1;
|
|
if (weekIndex < 0) {
|
|
weekIndex = 0;
|
|
}
|
|
return WEEKS[weekIndex];
|
|
}
|
|
}
|