梦幻许愿池逻辑修改

This commit is contained in:
oujunhui
2020-06-30 19:14:56 +08:00
parent d284cebe98
commit 833a912084
13 changed files with 255 additions and 47 deletions

View File

@@ -10,8 +10,10 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.IllegalFormatException;
import java.util.Locale;
import java.util.TimeZone;
/**
* Created by Zhanghuiping on 14/6/5.
@@ -815,4 +817,68 @@ public class TimeUtils {
return currYear == cacheYear;
}
/**
* 获得系统时间 年、月、日、小时、分钟
* @return HashMap
*/
public static int getTime24(){
Calendar calendar=Calendar.getInstance();
String hour = String.valueOf(calendar.get(Calendar.HOUR_OF_DAY));
String minute = String.valueOf(calendar.get(Calendar.MINUTE));
return Integer.parseInt(hour +minute);
}
public static boolean getTimeLimit(int start_hour,int start_minute,int end_hour,int end_minute) {
SimpleDateFormat hh = new SimpleDateFormat("HH", Locale.CHINA);
SimpleDateFormat mm = new SimpleDateFormat("mm", Locale.CHINA);
hh.setTimeZone(TimeZone.getTimeZone("GMT+08")); // 获取指定时区的时间
mm.setTimeZone(TimeZone.getTimeZone("GMT+08"));
Date date = new Date();
String hour = hh.format(date);
String minute = mm.format(date);
final int start = start_hour * start_minute;// 起始时间 8:00的分钟数
final int end = end_hour * end_minute;// 结束时间 19:00的分钟数
int minuteOfDay = Integer.parseInt(hour) * 60 + Integer.parseInt(minute);
Log.i("stf", "--hour:minute-->" + hour + ":" + minute);
LogUtil.print("start" +start);
LogUtil.print("end" +end);
LogUtil.print("minuteOfDay" +minuteOfDay);
if (minuteOfDay >= start && minuteOfDay <= end) {
LogUtil.print("工作时间内" + hour + ":" + minute);
return true;
} else {
if (start > end){
if (minuteOfDay >= start || minuteOfDay <= end){
return true;
}
}
LogUtil.print( "工作时间外" + hour + ":" + minute);
return false;
}
}
// public static boolean getTimeLimit() {
// SimpleDateFormat hh = new SimpleDateFormat("HH", Locale.CHINA);
// SimpleDateFormat mm = new SimpleDateFormat("mm", Locale.CHINA);
// hh.setTimeZone(TimeZone.getTimeZone("GMT+08")); // 获取指定时区的时间
// mm.setTimeZone(TimeZone.getTimeZone("GMT+08"));
// Date date = new Date();
// String hour = hh.format(date);
// String minute = mm.format(date);
// final int start = 8 * 60;// 起始时间 8:00的分钟数
// final int end = 19 * 60;// 结束时间 19:00的分钟数
// int minuteOfDay = Integer.parseInt(hour) * 60 + Integer.parseInt(minute);
// Log.i("stf", "--hour:minute-->" + hour + ":" + minute);
// if (minuteOfDay >= start && minuteOfDay <= end) {
// LogUtil.print("工作时间内" + hour + ":" + minute);
// return true;
// } else {
// LogUtil.print( "工作时间外" + hour + ":" + minute);
// return false;
// }
// }
}