List of usage examples for java.util Date setMinutes
@Deprecated public void setMinutes(int minutes)
From source file:gov.nih.nci.cabig.caaers.utils.DateUtils.java
public static Date today() { Calendar c = Calendar.getInstance(); Date d = c.getTime(); d.setHours(0);//from ww w. j a va2 s.com d.setMinutes(0); return d; }
From source file:gov.nih.nci.cabig.caaers.utils.DateUtils.java
/** * This is a convenient method to get tomorrow * @return//from w w w . j a va 2s . c om */ public static Date tomorrow() { Calendar c = Calendar.getInstance(); c.add(Calendar.DATE, 1); Date d = c.getTime(); d.setHours(0); d.setMinutes(0); return d; }
From source file:com.sccl.attech.common.utils.DateUtils.java
/** * ??//from w ww . j av a2 s. co m * @param date * @return */ public static Date getLastTimeDate(Date date) { Calendar cal = Calendar.getInstance(); int year = date.getYear() + 1900; int month = date.getMonth() + 1; cal.set(Calendar.YEAR, year); cal.set(Calendar.MONTH, month); cal.set(Calendar.DAY_OF_MONTH, 1); cal.add(Calendar.DAY_OF_MONTH, -1); Date lastDate = cal.getTime(); lastDate.setHours(23); lastDate.setMinutes(59); lastDate.setSeconds(59); return lastDate; }
From source file:com.sccl.attech.common.utils.DateUtils.java
/** * ??//from w w w . ja va 2 s . c o m * @param date * @return */ public static String getLastTime(Date date) { Calendar cal = Calendar.getInstance(); int year = date.getYear() + 1900; int month = date.getMonth() + 1; cal.set(Calendar.YEAR, year); cal.set(Calendar.MONTH, month); cal.set(Calendar.DAY_OF_MONTH, 1); cal.add(Calendar.DAY_OF_MONTH, -1); Date lastDate = cal.getTime(); lastDate.setHours(23); lastDate.setMinutes(59); lastDate.setSeconds(59); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return sdf.format(lastDate); }
From source file:com.sccl.attech.common.utils.DateUtils.java
/** * ?// ww w . j a v a2 s . c o m * @param date * @return */ public static Date getFirstTimeDate(Date date) { Calendar cal = Calendar.getInstance(); int year = date.getYear() + 1900; int month = date.getMonth() + 1; cal.set(Calendar.YEAR, year); cal.set(Calendar.MONTH, month); cal.set(Calendar.DAY_OF_MONTH, 1); cal.add(Calendar.DAY_OF_MONTH, -1); cal.set(Calendar.DAY_OF_MONTH, 1); Date firstDate = cal.getTime(); firstDate.setHours(0); firstDate.setMinutes(0); firstDate.setSeconds(0); return firstDate; }
From source file:com.sccl.attech.common.utils.DateUtils.java
/** * ?/*from ww w.j a v a 2 s .co m*/ * @param date * @return */ public static String getFirstTime(Date date) { Calendar cal = Calendar.getInstance(); int year = date.getYear() + 1900; int month = date.getMonth() + 1; cal.set(Calendar.YEAR, year); cal.set(Calendar.MONTH, month); cal.set(Calendar.DAY_OF_MONTH, 1); cal.add(Calendar.DAY_OF_MONTH, -1); cal.set(Calendar.DAY_OF_MONTH, 1); Date firstDate = cal.getTime(); firstDate.setHours(0); firstDate.setMinutes(0); firstDate.setSeconds(0); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return sdf.format(firstDate); }
From source file:cn.ipanel.apps.portalBackOffice.util.CommonsFiend.java
public static String[] getUpdateTime() { Date date = Calendar.getInstance().getTime(); date.setMinutes(date.getMinutes() + 1); String[] returnTime = new String[2]; returnTime[0] = DateFormatUtils.format(date, Defines.FORMAT_DATE_TIME_STRING); date.setHours(23);/* w w w. ja va 2s .c om*/ date.setMinutes(59); date.setSeconds(59); returnTime[1] = DateFormatUtils.format(date, Defines.FORMAT_DATE_TIME_STRING); return returnTime; }
From source file:com.ibuildapp.romanblack.TableReservationPlugin.utils.TableReservationHTTP.java
/** * This method call server to send email. * * @param template 1 - send confirmation mail to owner * 2 - send cancellation mail to owner * 3 - send confirmation mail to customer * 4 - send cancellation mail to customer * @param user user//from ww w. ja v a2s . c o m * @param orderInfo order info * @param appName application name * @param handler result handler * @return error code */ public static String sendMail(int template, User user, TableReservationInfo orderInfo, String appName, Handler handler) { HttpParams httpParameters = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParameters, 15000); HttpConnectionParams.setSoTimeout(httpParameters, 15000); HttpClient httpclient = new DefaultHttpClient(httpParameters); HttpPost httppost = new HttpPost(MAIL_ORDER_URL); Log.e(TAG, "MAIL_ORDER_URL = " + MAIL_ORDER_URL); List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); // restaurant details nameValuePairs.add(new BasicNameValuePair("app_name", appName)); nameValuePairs.add(new BasicNameValuePair("restaurant_name", orderInfo.getRestaurantName())); nameValuePairs.add(new BasicNameValuePair("restaurant_address", orderInfo.getRestaurantadress())); nameValuePairs.add(new BasicNameValuePair("restaurant_phone", orderInfo.getRestaurantphone())); // user details String userType = null; if (user.getAccountType() == User.ACCOUNT_TYPES.FACEBOOK) { userType = "facebook"; } else if (user.getAccountType() == User.ACCOUNT_TYPES.TWITTER) { userType = "twitter"; } else if (user.getAccountType() == User.ACCOUNT_TYPES.IBUILDAPP) { userType = "ibuildapp"; } else if (user.getAccountType() == User.ACCOUNT_TYPES.GUEST) { userType = "guest"; } nameValuePairs.add(new BasicNameValuePair("user_type", userType)); nameValuePairs.add(new BasicNameValuePair("user_id", user.getAccountId())); nameValuePairs.add(new BasicNameValuePair("user_name", user.getUserName())); nameValuePairs.add(new BasicNameValuePair("user_first_name", user.getUserFirstName())); nameValuePairs.add(new BasicNameValuePair("user_last_name", user.getUserLastName())); // order details Date tempDate = orderInfo.getOrderDate(); tempDate.setHours(orderInfo.getOrderTime().houres); tempDate.setMinutes(orderInfo.getOrderTime().minutes); String timeZone = timeZoneToString(); nameValuePairs.add(new BasicNameValuePair("time_zone", timeZone)); nameValuePairs.add(new BasicNameValuePair("order_date_time", Long.toString(tempDate.getTime() / 1000))); nameValuePairs.add(new BasicNameValuePair("order_persons", Integer.toString(orderInfo.getPersonsAmount()))); // contacts details nameValuePairs.add(new BasicNameValuePair("customer_email", user.getUserEmail())); nameValuePairs.add(new BasicNameValuePair("owner_email", orderInfo.getRestaurantmail())); nameValuePairs.add(new BasicNameValuePair("mail_type", Integer.toString(template))); // add security part nameValuePairs.add(new BasicNameValuePair("app_id", Statics.appId)); nameValuePairs.add(new BasicNameValuePair("token", Statics.appToken)); try { httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); } catch (UnsupportedEncodingException uEEx) { Log.e("", ""); handler.sendEmptyMessage(3); return "error"; } ResponseHandler<String> responseHandler = new BasicResponseHandler(); try { String strResponseSaveGoal = httpclient.execute(httppost, responseHandler); Log.d("sendMail", ""); return JSONParser.parseQueryError(strResponseSaveGoal); } catch (ConnectTimeoutException conEx) { handler.sendEmptyMessage(3); return "error"; } catch (ClientProtocolException ex) { Log.d("sendMail", ""); handler.sendEmptyMessage(3); return "error"; } catch (IOException ex) { Log.d("sendMail", ""); handler.sendEmptyMessage(3); return "error"; } }
From source file:com.sccl.attech.common.utils.DateUtils.java
/** * ?? ,/*from w w w. ja v a 2 s.co m*/ * @param endDate * @return */ @SuppressWarnings("deprecation") public static Date getResTime(Date pointDate) { Date date = new Date(); if (pointDate != null) { int hours = getHours(pointDate); int minutes = getMin(pointDate); date.setHours(hours); date.setMinutes(minutes); } return date; }
From source file:com.ibuildapp.romanblack.TableReservationPlugin.utils.TableReservationHTTP.java
/** * This method sends HTTP request to add order. * * @param user/* www . j a va 2 s .c om*/ * @param handler * @param orderInfo * @return */ public static String sendAddOrderRequest(User user, Handler handler, TableReservationInfo orderInfo) { HttpParams httpParameters = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParameters, 15000); HttpConnectionParams.setSoTimeout(httpParameters, 15000); HttpClient httpclient = new DefaultHttpClient(httpParameters); HttpPost httppost = new HttpPost(ADD_ORDER_URL); Log.e(TAG, "ADD_ORDER_URL = " + ADD_ORDER_URL); MultipartEntity multipartEntity = new MultipartEntity(); // user details String userType = null; String orderUUID = null; try { if (user.getAccountType() == User.ACCOUNT_TYPES.FACEBOOK) { userType = "facebook"; multipartEntity.addPart("order_customer_name", new StringBody( user.getUserFirstName() + " " + user.getUserLastName(), Charset.forName("UTF-8"))); } else if (user.getAccountType() == User.ACCOUNT_TYPES.TWITTER) { userType = "twitter"; multipartEntity.addPart("order_customer_name", new StringBody(user.getUserName(), Charset.forName("UTF-8"))); } else if (user.getAccountType() == User.ACCOUNT_TYPES.IBUILDAPP) { userType = "ibuildapp"; multipartEntity.addPart("order_customer_name", new StringBody(user.getUserName(), Charset.forName("UTF-8"))); } else if (user.getAccountType() == User.ACCOUNT_TYPES.GUEST) { userType = "guest"; multipartEntity.addPart("order_customer_name", new StringBody("Guest", Charset.forName("UTF-8"))); } multipartEntity.addPart("user_type", new StringBody(userType, Charset.forName("UTF-8"))); multipartEntity.addPart("user_id", new StringBody(user.getAccountId(), Charset.forName("UTF-8"))); multipartEntity.addPart("app_id", new StringBody(orderInfo.getAppid(), Charset.forName("UTF-8"))); multipartEntity.addPart("module_id", new StringBody(orderInfo.getModuleid(), Charset.forName("UTF-8"))); // order UUID orderUUID = UUID.randomUUID().toString(); multipartEntity.addPart("order_uid", new StringBody(orderUUID, Charset.forName("UTF-8"))); // order details Date tempDate = orderInfo.getOrderDate(); tempDate.setHours(orderInfo.getOrderTime().houres); tempDate.setMinutes(orderInfo.getOrderTime().minutes); tempDate.getTimezoneOffset(); String timeZone = timeZoneToString(); multipartEntity.addPart("time_zone", new StringBody(timeZone, Charset.forName("UTF-8"))); multipartEntity.addPart("order_date_time", new StringBody(Long.toString(tempDate.getTime() / 1000), Charset.forName("UTF-8"))); multipartEntity.addPart("order_persons", new StringBody(Integer.toString(orderInfo.getPersonsAmount()), Charset.forName("UTF-8"))); multipartEntity.addPart("order_spec_request", new StringBody(orderInfo.getSpecialRequest(), Charset.forName("UTF-8"))); multipartEntity.addPart("order_customer_phone", new StringBody(orderInfo.getPhoneNumber(), Charset.forName("UTF-8"))); multipartEntity.addPart("order_customer_email", new StringBody(orderInfo.getCustomerEmail(), Charset.forName("UTF-8"))); // add security part multipartEntity.addPart("app_id", new StringBody(Statics.appId, Charset.forName("UTF-8"))); multipartEntity.addPart("token", new StringBody(Statics.appToken, Charset.forName("UTF-8"))); } catch (Exception e) { Log.d("", ""); } httppost.setEntity(multipartEntity); ResponseHandler<String> responseHandler = new BasicResponseHandler(); try { String strResponseSaveGoal = httpclient.execute(httppost, responseHandler); Log.d("sendAddOrderRequest", ""); String res = JSONParser.parseQueryError(strResponseSaveGoal); if (res == null || res.length() == 0) { return orderUUID; } else { handler.sendEmptyMessage(ADD_REQUEST_ERROR); return null; } } catch (ConnectTimeoutException conEx) { handler.sendEmptyMessage(ADD_REQUEST_ERROR); return null; } catch (ClientProtocolException ex) { handler.sendEmptyMessage(ADD_REQUEST_ERROR); return null; } catch (IOException ex) { handler.sendEmptyMessage(ADD_REQUEST_ERROR); return null; } }