List of usage examples for java.util Date getTimezoneOffset
@Deprecated public int getTimezoneOffset()
From source file:com.projity.util.DateTime.java
public static long fromGmt(long d) { if (d == 0)//from w w w. j a v a2 s.c om return 0; Date date = new Date(d); return new Date(date.getTime() + (isGmtConvertion() ? 60000L * date.getTimezoneOffset() : 0)).getTime(); }
From source file:com.projity.util.DateTime.java
public static long gmt(Date date) { if (date == null) return 0; return date.getTime() - (isGmtConvertion() ? 60000L * date.getTimezoneOffset() : 0); }
From source file:com.projity.util.DateTime.java
public static Date fromGmt(Date date) { if (date == null) return null; return new Date(date.getTime() + (isGmtConvertion() ? 60000L * date.getTimezoneOffset() : 0)); }
From source file:com.ibuildapp.romanblack.TableReservationPlugin.utils.TableReservationHTTP.java
/** * This method sends HTTP request to add order. * * @param user/*from w w w. j a v a 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; } }
From source file:com.google.sampling.experiential.server.EventRetriever.java
public static Date adjustTimeToTimezoneIfNecesssary(String tz, Date responseTime) { if (responseTime == null) { return null; }//from www .j a v a 2s .c o m DateTimeZone timezone = null; if (tz != null) { timezone = DateTimeZone.forID(tz); } if (timezone != null && responseTime.getTimezoneOffset() != timezone.getOffset(responseTime.getTime())) { responseTime = new DateTime(responseTime).withZone(timezone).toDate(); } return responseTime; }
From source file:org.activequant.util.charting.IntradayMarketTimeline.java
/** * Returns <code>true</code> if a range of dates are contained in the * timeline.//w w w . java2s .c om * * @param fromDate the start of the range to verify. * @param toDate the end of the range to verify. * * @return <code>true</code> if the range is contained in the timeline or * <code>false</code> otherwise */ @SuppressWarnings("deprecation") public boolean containsDomainRange(Date fromDate, Date toDate) { //normalize to GMT return this.containsDomainRange(fromDate.getTimezoneOffset() + fromDate.getTime(), toDate.getTimezoneOffset() + toDate.getTime()); }
From source file:com.ibm.xsp.webdav.resource.DAVResourceDominoDocuments.java
@SuppressWarnings("deprecation") private void setup(Document curDoc) { try {/*ww w. j a v a 2 s . c o m*/ // LOGGER.info(getCallingMethod()+":"+"Start setup..."); @SuppressWarnings("rawtypes") Vector allEmbedded = DominoProxy.evaluate("@AttachmentNames", curDoc); // LOGGER.info(getCallingMethod()+":"+"All Embedded computed"); int numOfAttachments = allEmbedded.isEmpty() ? 0 : (allEmbedded.get(0).equals("") ? 0 : allEmbedded.size()); String docID = curDoc.getUniversalID(); this.setDocumentUniqueID(docID); // LOGGER.info("Num of attachments="+new // Integer(numOfAttachments).toString()); boolean readOnly = this.checkReadOnlyAccess(curDoc); this.setReadOnly(readOnly); LOGGER.info("Creation date for " + curDoc.getUniversalID() + " =" + curDoc.getCreated().toString() + "; Time zone=" + curDoc.getCreated().getZoneTime() + "; Local time=" + curDoc.getCreated().getLocalTime()); Date curCreationDate = curDoc.getCreated().toJavaDate(); LOGGER.info("Current date in Java is " + curCreationDate.toString() + "Time zone=" + new Integer(curCreationDate.getTimezoneOffset()).toString() + "; Locale time is:" + curCreationDate.toLocaleString()); if (curDoc.hasItem("DAVCreated")) { // Item davCreated=curDoc.getFirstItem("DAVCreated"); @SuppressWarnings("rawtypes") Vector times = curDoc.getItemValueDateTimeArray("DAVCreated"); if (times != null) { if (times.size() > 0) { Object time = times.elementAt(0); if (time != null) { if (time.getClass().getName().endsWith("DateTime")) { curCreationDate = ((DateTime) time).toJavaDate(); if (curCreationDate == null) { curCreationDate = curDoc.getCreated().toJavaDate(); } } } } } } Date curChangeDate = curDoc.getLastModified().toJavaDate(); if (curDoc.hasItem("DAVModified")) { @SuppressWarnings("rawtypes") Vector times = curDoc.getItemValueDateTimeArray("DAVModified"); if (times != null) { if (times.size() > 0) { Object time = times.elementAt(0); if (time != null) { if (time.getClass().getName().endsWith("DateTime")) { curChangeDate = ((DateTime) time).toJavaDate(); if (curChangeDate == null) { curChangeDate = curDoc.getLastModified().toJavaDate(); } } } } } } this.setCreationDate(curCreationDate); this.setLastModified(curChangeDate); LOGGER.info("Creation date is set to " + this.getCreationDate().toString()); LOGGER.info("Last modified date is set to " + this.getLastModified().toString()); String pubHRef = ((IDAVAddressInformation) this.getRepository()).getPublicHref(); // LOGGER.info("THIS getpublichref="+this.getPublicHref()); String curAttName = null; if (numOfAttachments == 0) { // LOGGER.info(getCallingMethod()+":"+"Start setting resource"); this.setName(docID); String name = curDoc.getItemValueString( ((DAVRepositoryDominoDocuments) (this.getRepository())).getDirectoryField()); this.setName(name); if (this.getPublicHref().equals("")) { // try{ this.setPublicHref(pubHRef + "/" + name); // URLEncoder.encode(name, "UTF-8")); // }catch(UnsupportedEncodingException e){ // LOGGER.error(e); // } } this.setCollection(true); this.setInternalAddress( ((IDAVAddressInformation) this.getRepository()).getInternalAddress() + "/" + docID); this.setResourceType("NotesDocument"); this.setMember(false); this.setContentLength(0L); // this.fetchChildren(); } else { curAttName = allEmbedded.get(0).toString(); // LOGGER.info("Attachment name is "+curAttName); this.setMember(true); this.setResourceType("NotesAttachment"); if (this.getPublicHref().equals("")) { try { this.setPublicHref(pubHRef + "/" + URLEncoder.encode(curAttName, "UTF-8")); } catch (UnsupportedEncodingException e) { LOGGER.error(e); } // this.setPublicHref( pubHRef+"/"+curAttName); } this.setInternalAddress(((IDAVAddressInformation) this.getRepository()).getInternalAddress() + "/" + docID + "/$File/" + curAttName); this.setCollection(false); this.setName(curAttName); EmbeddedObject curAtt = curDoc.getAttachment(curAttName); if (curAtt == null) { // LOGGER.info("Error! Current Embedded is null"); return; } else { // LOGGER.info("Embedded is not null. OK! "); } Long curSize = new Long(curAtt.getFileSize()); this.setContentLength(curSize); } // LOGGER.info("Current res realized! pubHREF="+this.getPublicHref()+"; Internal Address="+this.getInternalAddress()+"; "); } catch (NotesException ne) { LOGGER.error("ERROR! Can not set; " + ne.getMessage()); } }
From source file:org.i4change.app.remote.UserService.java
public Long saveOrUpdateUser(String SID, Map argObjectMap) { try {//from w w w . j av a 2 s . c o m Long user_idClient = null; if (argObjectMap.get("user_idClient") != null) { user_idClient = Long.valueOf(argObjectMap.get("user_idClient").toString()).longValue(); } //log.error("saveOrUpdateUser1: "); Long users_id = this.sessionmanagement.checkSession(SID); //log.error("saveOrUpdateUser2: "); Long user_level = this.userDaoImpl.getUserLevelByID(users_id); // log.error("saveOrUpdateUser1: "+argObjectMap.get("organisations")); // log.error("saveOrUpdateUser2: "+argObjectMap.get("organisations").getClass()); // log.error("saveOrUpdateUser3: "+argObjectMap.get("user_idClient")); //TODO: there is a BUG here: value send is Time as GMT but here it gets CEST which is wrong //but maybe a OS-related-issue //log.error("saveOrUpdateUser4: "+argObjectMap.get("userage")); //log.error("saveOrUpdateUser5: "+argObjectMap.get("userage").getClass()); Vector organisations = (Vector) argObjectMap.get("organisations"); Date age = null; if (argObjectMap.get("userage") instanceof Date) { age = (Date) argObjectMap.get("userage"); log.error("saveOrUpdateUser7: " + age.getTimezoneOffset()); } log.debug("argObjectMap: " + argObjectMap); Date expireDate = null; if (argObjectMap.get("expireDate") != null && !argObjectMap.get("expireDate").equals("null")) { expireDate = CalendarPatterns.parseDate(argObjectMap.get("expireDate").toString()); } Long maxWorkDays = null; if (argObjectMap.get("maxWorkDays") != null && !argObjectMap.get("maxWorkDays").equals("null")) { maxWorkDays = Long.valueOf(argObjectMap.get("maxWorkDays").toString()).longValue(); } Float pricePerUser = null; if (argObjectMap.get("pricePerUser") != null && !argObjectMap.get("pricePerUser").equals("null")) { pricePerUser = Float.valueOf(argObjectMap.get("pricePerUser").toString()).floatValue(); } Vector discounts = null; if (argObjectMap.get("discounts") != null && !argObjectMap.get("discounts").equals("null")) { discounts = (Vector) argObjectMap.get("discounts"); } //log.debug("saveOrUpdateUser6: "+age); log.debug(user_level); log.debug(user_idClient); log.debug(Long.valueOf(argObjectMap.get("level_id").toString()).longValue()); log.debug(argObjectMap.get("login").toString()); log.debug(argObjectMap.get("password").toString()); log.debug(argObjectMap.get("lastname").toString()); log.debug(argObjectMap.get("firstname").toString()); log.debug(age); log.debug(argObjectMap.get("street").toString()); log.debug(argObjectMap.get("additionalname").toString()); log.debug(argObjectMap.get("zip").toString()); log.debug(Long.valueOf(argObjectMap.get("states_id").toString()).longValue()); log.debug(argObjectMap.get("town").toString()); log.debug(Integer.valueOf(argObjectMap.get("availible").toString()).intValue()); log.debug(argObjectMap.get("telefon").toString()); log.debug(argObjectMap.get("fax").toString()); log.debug(argObjectMap.get("mobil").toString()); log.debug(argObjectMap.get("email").toString()); log.debug(argObjectMap.get("comment").toString()); log.debug(Integer.valueOf(argObjectMap.get("status").toString()).intValue()); log.debug(organisations); log.debug(Integer.valueOf(argObjectMap.get("title_id").toString()).intValue()); log.debug(Boolean.valueOf(argObjectMap.get("isPending").toString()).booleanValue()); log.debug(expireDate); log.debug(maxWorkDays); log.debug(Boolean.valueOf(argObjectMap.get("useDefaultDiscounts").toString()).booleanValue()); log.debug(Boolean.valueOf(argObjectMap.get("unlimitedLicenses").toString()).booleanValue()); log.debug(Long.valueOf(argObjectMap.get("licenseUserPayed").toString()).longValue()); log.debug(Long.valueOf(argObjectMap.get("licenseUserUsed").toString()).longValue()); log.debug(pricePerUser); log.debug(discounts); if (user_idClient == null || user_idClient == 0) { return this.usermanagement.addUserByAdministrationPanel(user_level, Long.valueOf(argObjectMap.get("level_id").toString()).longValue(), Integer.valueOf(argObjectMap.get("availible").toString()).intValue(), Integer.valueOf(argObjectMap.get("status").toString()).intValue(), argObjectMap.get("login").toString(), argObjectMap.get("password").toString(), argObjectMap.get("lastname").toString(), argObjectMap.get("firstname").toString(), argObjectMap.get("email").toString(), age, argObjectMap.get("street").toString(), argObjectMap.get("additionalname").toString(), argObjectMap.get("fax").toString(), argObjectMap.get("zip").toString(), Long.valueOf(argObjectMap.get("states_id").toString()).longValue(), argObjectMap.get("town").toString(), 0, organisations, Boolean.valueOf(argObjectMap.get("isPending").toString()).booleanValue(), expireDate, maxWorkDays, Boolean.valueOf(argObjectMap.get("useDefaultDiscounts").toString()).booleanValue(), Boolean.valueOf(argObjectMap.get("unlimitedLicenses").toString()).booleanValue(), Long.valueOf(argObjectMap.get("licenseUserPayed").toString()).longValue(), Long.valueOf(argObjectMap.get("licenseUserUsed").toString()).longValue(), pricePerUser, discounts); } else { return this.usermanagement.updateByAdministrationPanel(user_level, user_idClient, Long.valueOf(argObjectMap.get("level_id").toString()).longValue(), argObjectMap.get("login").toString(), argObjectMap.get("password").toString(), argObjectMap.get("lastname").toString(), argObjectMap.get("firstname").toString(), age, argObjectMap.get("street").toString(), argObjectMap.get("additionalname").toString(), argObjectMap.get("zip").toString(), Long.valueOf(argObjectMap.get("states_id").toString()).longValue(), argObjectMap.get("town").toString(), Integer.valueOf(argObjectMap.get("availible").toString()).intValue(), argObjectMap.get("telefon").toString(), argObjectMap.get("fax").toString(), argObjectMap.get("mobil").toString(), argObjectMap.get("email").toString(), argObjectMap.get("comment").toString(), Integer.valueOf(argObjectMap.get("status").toString()).intValue(), organisations, Integer.valueOf(argObjectMap.get("title_id").toString()).intValue(), Boolean.valueOf(argObjectMap.get("isPending").toString()).booleanValue(), expireDate, maxWorkDays, Boolean.valueOf(argObjectMap.get("useDefaultDiscounts").toString()).booleanValue(), Boolean.valueOf(argObjectMap.get("unlimitedLicenses").toString()).booleanValue(), Long.valueOf(argObjectMap.get("licenseUserPayed").toString()).longValue(), Long.valueOf(argObjectMap.get("licenseUserUsed").toString()).longValue(), pricePerUser, discounts); } } catch (Exception ex) { log.error("[saveOrUpdateUser]: ", ex); } return null; }
From source file:org.i4change.app.remote.UserService.java
public Long saveOrUpdateUserOnly(String SID, Object regObjectObj) { try {//from ww w . ja v a 2 s .c om log.debug("saveOrUpdateUserOnly: " + regObjectObj.getClass().getName()); Hashtable argObjectMap = (Hashtable) regObjectObj; Long user_idClient = null; if (argObjectMap.get("user_idClient") != null) { user_idClient = Long.valueOf(argObjectMap.get("user_idClient").toString()).longValue(); } //log.error("saveOrUpdateUser1: "); Long users_id = this.sessionmanagement.checkSession(SID); //log.error("saveOrUpdateUser2: "); Long user_level = this.userDaoImpl.getUserLevelByID(users_id); // log.error("saveOrUpdateUser1: "+argObjectMap.get("organisations")); // log.error("saveOrUpdateUser2: "+argObjectMap.get("organisations").getClass()); // log.error("saveOrUpdateUser3: "+argObjectMap.get("user_idClient")); //TODO: there is a BUG here: value send is Time as GMT but here it gets CEST which is wrong //but maybe a OS-related-issue //log.error("saveOrUpdateUser4: "+argObjectMap.get("userage")); //log.error("saveOrUpdateUser5: "+argObjectMap.get("userage").getClass()); if (AuthLevelmanagement.checkUserLevel(user_level)) { Date age = null; if (argObjectMap.get("userage") instanceof Date) { age = (Date) argObjectMap.get("userage"); log.error("saveOrUpdateUserOnly TimeZoneOffset: " + age.getTimezoneOffset()); } if (user_idClient == null || user_idClient == 0) { return this.usermanagement.addUserOrgModerator(users_id, Integer.valueOf(argObjectMap.get("availible").toString()).intValue(), Integer.valueOf(argObjectMap.get("status").toString()).intValue(), argObjectMap.get("login").toString(), argObjectMap.get("password").toString(), argObjectMap.get("lastname").toString(), argObjectMap.get("firstname").toString(), argObjectMap.get("email").toString(), age, argObjectMap.get("street").toString(), argObjectMap.get("additionalname").toString(), argObjectMap.get("fax").toString(), argObjectMap.get("zip").toString(), Long.valueOf(argObjectMap.get("states_id").toString()).longValue(), argObjectMap.get("town").toString(), 0, Long.valueOf(argObjectMap.get("organisation_id").toString()).longValue(), Boolean.valueOf(argObjectMap.get("isModerator").toString()).booleanValue(), Boolean.valueOf(argObjectMap.get("sendMail").toString()).booleanValue()); } else { return this.usermanagement.updateUserByOrgModerator(users_id, user_idClient, argObjectMap.get("login").toString(), argObjectMap.get("password").toString(), argObjectMap.get("lastname").toString(), argObjectMap.get("firstname").toString(), age, argObjectMap.get("street").toString(), argObjectMap.get("additionalname").toString(), argObjectMap.get("zip").toString(), Long.valueOf(argObjectMap.get("states_id").toString()).longValue(), argObjectMap.get("town").toString(), Integer.valueOf(argObjectMap.get("availible").toString()).intValue(), argObjectMap.get("telefon").toString(), argObjectMap.get("fax").toString(), argObjectMap.get("mobil").toString(), argObjectMap.get("email").toString(), argObjectMap.get("comment").toString(), Integer.valueOf(argObjectMap.get("status").toString()).intValue(), Boolean.valueOf(argObjectMap.get("isModerator").toString()).booleanValue(), Integer.valueOf(argObjectMap.get("title_id").toString()).intValue(), Long.valueOf(argObjectMap.get("organisation_id").toString()).longValue(), Boolean.valueOf(argObjectMap.get("sendMail").toString()).booleanValue()); } } //log.error("saveOrUpdateUser6: "+age); } catch (Exception ex) { log.error("[saveOrUpdateUser]: ", ex); } return null; }
From source file:org.smartfrog.services.deployapi.engine.ServerInstance.java
@SuppressWarnings("deprecation") private Element makeStaticStatus() { Element status = Xom5Utils.element(Constants.PROPERTY_PORTAL_STATIC_PORTAL_STATUS); Element portal = XomHelper.apiElement(StatusElements.PORTAL); status.appendChild(portal);//www . java 2s . c om portal.appendChild(XomHelper.apiElement(StatusElements.NAME, Constants.BUILD_INFO_IMPLEMENTATION_NAME)); portal.appendChild(XomHelper.apiElement(StatusElements.BUILD, BUILD_TIMESTAMP)); portal.appendChild(XomHelper.apiElement(StatusElements.LOCATION, location)); portal.appendChild(XomHelper.apiElement(StatusElements.HOME, Constants.BUILD_INFO_HOMEPAGE)); Date now = new Date(); BigInteger tzoffset = BigInteger.valueOf(now.getTimezoneOffset()); portal.appendChild(XomHelper.apiElement(StatusElements.TIMEZONE_UTCOFFSET, tzoffset.toString())); Element languages = XomHelper.apiElement(StatusElements.LANGUAGES); Element cdl = XomHelper.apiElement(StatusElements.ITEM); Element name = XomHelper.apiElement(StatusElements.NAME, Constants.BUILD_INFO_CDL_LANGUAGE); Element uri = XomHelper.apiElement(StatusElements.URI, Constants.XML_CDL_NAMESPACE); cdl.appendChild(name); cdl.appendChild(uri); languages.appendChild(cdl); status.appendChild(languages); Element sfrog = XomHelper.apiElement(StatusElements.ITEM); name = XomHelper.apiElement(StatusElements.NAME, Constants.BUILD_INFO_SF_LANGUAGE); uri = XomHelper.apiElement(StatusElements.URI, Constants.SMARTFROG_NAMESPACE); sfrog.appendChild(name); sfrog.appendChild(uri); languages.appendChild(sfrog); Element notifications = XomHelper.apiElement(StatusElements.NOTIFICATIONS); Element wsrf = XomHelper.apiElement(StatusElements.ITEM, Constants.WSRF_WSNT_NAMESPACE); notifications.appendChild(wsrf); status.appendChild(notifications); Element options = XomHelper.apiElement(StatusElements.OPTIONS); status.appendChild(options); return status; }