Here you can find the source of checkTime(int id)
Parameter | Description |
---|---|
id | the id |
public static String checkTime(int id)
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.util.Calendar; import java.util.GregorianCalendar; import java.util.Locale; public class Main { /**//from ww w.j a v a2 s. co m * Check time. * * @param id the id * @return the string */ public static String checkTime(int id) { String bol = ""; Calendar tt = Calendar.getInstance(); String currDate = getNowDate(); System.out.println("currDate=" + currDate); int result = tt.get(Calendar.DAY_OF_WEEK); int shour = tt.get(Calendar.HOUR_OF_DAY); if (id == 3) { switch (result) { case 1: break; case 7: if ((shour >= 8) && (shour < 12)) { bol = "disabled"; break; } default: if ((shour >= 8) && (shour < 12)) { bol = "disabled"; break; } else if ((shour >= 14) && (shour < 17)) { bol = "disabled"; break; } } } return bol; } /** * Gets the now date. * * @return the now date */ public static String getNowDate() { GregorianCalendar gcNow = new GregorianCalendar(); java.util.Date dNow = gcNow.getTime(); DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.SIMPLIFIED_CHINESE); return df.format(dNow); } }