Here you can find the source of IsTechStatisticWorkTime(Timestamp timestamp)
Parameter | Description |
---|---|
timestamp | a parameter |
public static boolean IsTechStatisticWorkTime(Timestamp timestamp)
//package com.java2s; //License from project: Open Source License import java.sql.Timestamp; import java.util.Calendar; import java.util.Date; public class Main { public static boolean IsTechStatisticWorkTime(Timestamp timestamp) { try {// ww w . j a v a 2 s . c o m int weekDay = getDayOfWeek(timestamp); if (weekDay >= 1 && weekDay <= 5) { if ((timestamp.getHours() >= 8 && timestamp.getHours() < 22)) { return true; } } else { if (((timestamp.getHours() >= 10)) && timestamp.getHours() < 19) { return true; } } } catch (Exception e) { e.printStackTrace(); } return false; } public static int getDayOfWeek(Timestamp timestamp) { Calendar cal = Calendar.getInstance(); Date date = new Date(timestamp.getTime()); cal.setTime(date); int dayForWeek = 0; dayForWeek = cal.get(Calendar.DAY_OF_WEEK); if (dayForWeek == 1) { dayForWeek = 7; } else { dayForWeek = dayForWeek - 1; } return dayForWeek; } }