List of usage examples for java.util Date toString
public String toString()
where:dow mon dd hh:mm:ss zzz yyyy
From source file:com.fota.firmMgt.controller.FirmUpdateCTR.java
/** * ?// www. j a v a 2 s. c o m * @param vo * @param model * @return */ @RequestMapping(value = "/add") @ResponseBody public ModelAndView add(HttpServletRequest request, HttpServletResponse response, @ModelAttribute("firmUpdateVO") FirmUpdateVO vo, ModelMap model) throws Exception { if (PropUtil.getPropValue("onm.mode").equals("P")) { Runtime.getRuntime() .exec("sudo mount -t nfs 10.220.250.11:/vol/vol2/c-dms-pd1-w01 /home/jboss/firmware"); logger.warn("Firmware Modify - File Upload Start... " + "( Mount On : sudo mount -t nfs 10.220.250.11:/vol/vol2/c-dms-pd1-w01 /home/jboss/firmware )"); // ?? ? ? 2~3 sleep 3 Thread.sleep(3000); } Date now = new Date(); logger.info("File update start : " + now.toString()); // ? ? File temp_folder = new File(DEFAULT_PATH); if (!temp_folder.exists() || !temp_folder.isDirectory()) { temp_folder.mkdirs(); } // ?? : 500M int maxfilesize = 500 * 1024 * 1024; MultipartRequest multi = null; File upfile = null; try { // ? multi = new MultipartRequest(request, DEFAULT_PATH, maxfilesize, "utf-8"); upfile = new File(DEFAULT_PATH + multi.getFilesystemName("file")); vo.setFileName(VoV.valid(upfile.getName(), 200, 8)); vo.setFileSize(Integer.parseInt(String.valueOf(upfile.length()))); //vo.setBizTypeId(VoV.valid(multi.getParameter("bizTypeId"), 30, 4)); //vo.setSvcId(VoV.valid(multi.getParameter("svcId"), 30, 4)); //vo.setMakerId(VoV.valid(multi.getParameter("makerId"), 30, 4)); vo.setDevModelId(VoV.valid(multi.getParameter("devModelId"), 30, 4)); vo.setFotaType(VoV.valid(multi.getParameter("fotaType"), 50)); if (!vo.getFotaType().equals("") && !vo.getFotaType().equals("PUSH") && !vo.getFotaType().equals("POLLING") && !vo.getFotaType().equals("PUSHPOLLING")) throw new Exception(); vo.setFirmwareId(VoV.valid(multi.getParameter("firmwareId"), 30, 4)); //vo.setFirmwareDesc(VoV.valid(multi.getParameter("firmwareDesc"), 1000, 9)); vo.setFirmwareVer(VoV.valid(multi.getParameter("firmwareVer"), 100, 4)); vo.setFirmwareMakerVer(VoV.valid(multi.getParameter("firmwareMakerVer"), 100, 8)); vo.setVerMemo(VoV.valid(multi.getParameter("verMemo"), 1000, 9)); // ? ? String path = DEFAULT_PATH + vo.getDevModelId() + "/"; File pysicalfolder = new File(path); if (!pysicalfolder.exists() || !pysicalfolder.isDirectory()) { pysicalfolder.mkdirs(); } vo.setFilePath(VoV.valid(path, 200)); // ??? File destFile = new File(path + upfile.getName()); if (destFile.exists()) { destFile.delete(); } FileUtils.moveFile(upfile, destFile); //CRC, '0' vo.setCrc("0"); vo.setCretNm(((UserLoginVO) request.getSession().getAttribute("userInfo")).getUserNm()); } catch (Exception e) { // ?? // ??? ? ? if (upfile != null && upfile.exists()) { upfile.delete(); } String errorMSG = e.getMessage(); if (errorMSG.indexOf("exceeds") != 0) { model.addAttribute("error", "?? 500MB ?."); } logger.info("File update error : " + errorMSG); response.setStatus(500); return new ModelAndView(ajaxMainView, model); } mySVC.add(vo); now = new Date(); logger.info("File update end : " + now.toString()); // Runtime.getRuntime().exec("sudo umount /home/jboss/firmware"); // logger.warn("Firmware Modify - File Upload end... " // + "( Mount Off : sudo umount /home/jboss/firmware )"); return new ModelAndView(ajaxMainView, model); }
From source file:com.z3r0byte.magis.CalendarActivity.java
private void setToolbarTitle(Date date) { if (date.toString().substring(0, 10).equals(DateUtils.getToday().toString().substring(0, 10))) { mToolbar.setTitle(R.string.msg_today); } else {/*from ww w .j av a 2 s.c om*/ mToolbar.setTitle(DateUtils.formatDate(date, "EEEE dd MMM")); } }
From source file:edu.lafayette.metadb.web.authentication.CheckSession.java
/** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) *///w w w . j av a 2 s . c om protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub PrintWriter out = response.getWriter(); JSONObject output = new JSONObject(); try { HttpSession session = request.getSession(false); if (session != null && checkUser(session)) { String name = (String) session.getAttribute(Global.SESSION_USERNAME); User user = UserManDAO.getUserData(name); long last_login = ((Long) session.getAttribute(Global.SESSION_LOGIN_TIME)).longValue(); Date date = new Date(last_login + 5 * 3600 * 1000); output.put("username", name); output.put("admin", user.getType().equals(Global.USER_ADMIN)); output.put("local", user.getAuthType().equals("Local")); output.put("last_login", date.toString()); output.put("success", true); output.put("parser_running", MetaDbHelper.getParserStatus()); output.put("record_count", MetaDbHelper.getItemCount()); output.put("log_types", Global.eventTypes); String[] last_page = UserManDAO.getLastProj(name).split(";"); if (last_page.length > 1) { output.put("last_proj", last_page[0]); output.put("last_item", last_page[1]); } } else { output.put("success", false); output.put("message", "Your session has expired"); } out.print(output); } catch (Exception e) { MetaDbHelper.logEvent(e); } response.setContentType("application/x-json"); out.flush(); }
From source file:com.nextgis.mobile.forms.CameraFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); sensorManager.unregisterListener(sensorListener); if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE && resultCode == Activity.RESULT_OK) { //add angle float dfAngle = 0; try {/*from w w w . java 2 s .c om*/ ExifInterface exif = new ExifInterface(imgFile.getPath()); String sDate = exif.getAttribute(ExifInterface.TAG_DATETIME); Date datetime = stringToDate(sDate, "yyyy:MM:dd HH:mm:ss"); Log.d(TAG, "image date: " + datetime.toString()); long testMilli = datetime.getTime(); long nDif = 1000000; for (long n : mAngles.keySet()) { long nDifTmp = Math.abs(testMilli - n); if (nDifTmp < nDif) { nDif = nDifTmp; dfAngle = (Float) mAngles.get(n); } } Log.d(TAG, "image angle: " + dfAngle); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } String listItem; if (data != null) { Uri outPath = data.getData(); listItem = outPath.getLastPathSegment(); } else { listItem = fileName; } HashMap<String, Object> hm = new HashMap<String, Object>(); hm.put(IMG_NAME, listItem); String sAngle = CompassFragment.formatNumber(dfAngle, 0, 0) + CompassFragment.DEGREE_CHAR + " " + CompassFragment.getDirectionCode(dfAngle, getResources()); hm.put(IMG_ROT, sAngle); listItems.add(hm); adapter.notifyDataSetChanged(); InputPointActivity activity = (InputPointActivity) getActivity(); if (activity == null) return; activity.AddImage(listItem, dfAngle); } }
From source file:admin.java
private String getGMT7(Date date) { DateFormat gmtFormat = new SimpleDateFormat(); TimeZone gmtTime = TimeZone.getTimeZone("GMT+7"); gmtFormat.setTimeZone(gmtTime);//from www . j a va2 s .com return date.toString(); }
From source file:org.jboss.seam.wiki.core.ui.FeedServlet.java
private String calculateEtag(Date date) { Hash hash = new Hash(); return hash.hash(date.toString()); }
From source file:com.fota.firmMgt.controller.FirmRegiCTR.java
/** * ?/*from w ww . ja va2 s . c om*/ * @param vo * @param model * @return */ @RequestMapping(value = "/regi") @ResponseBody public ModelAndView regi(HttpServletRequest request, HttpServletResponse response, @ModelAttribute("firmUpdateVO") FirmUpdateVO vo, ModelMap model) throws Exception { if (PropUtil.getPropValue("onm.mode").equals("P")) { Runtime.getRuntime() .exec("sudo mount -t nfs 10.220.250.11:/vol/vol2/c-dms-pd1-w01 /home/jboss/firmware"); logger.warn("Firmware Regist - File Upload Start... " + "( Mount On : sudo mount -t nfs 10.220.250.11:/vol/vol2/c-dms-pd1-w01 /home/jboss/firmware )"); // ?? ? ? 2~3 sleep 3 Thread.sleep(3000); } Date now = new Date(); logger.info("File update start : " + now.toString()); // ? ? File temp_folder = new File(DEFAULT_PATH); if (!temp_folder.exists() || !temp_folder.isDirectory()) { temp_folder.mkdirs(); } // ?? : 500M int maxfilesize = 500 * 1024 * 1024; MultipartRequest multi = null; File upfile = null; try { // ? multi = new MultipartRequest(request, DEFAULT_PATH, maxfilesize, "utf-8"); upfile = new File(DEFAULT_PATH + multi.getFilesystemName("file")); vo.setFileName(VoV.valid(upfile.getName(), 200, 8)); // 2015-10-07 // vo.setFileSize(String.valueOf(upfile.length())); vo.setFileSize(Integer.parseInt(String.valueOf(upfile.length()))); vo.setBizTypeId(VoV.valid(multi.getParameter("bizTypeId"), 30)); vo.setSvcId(VoV.valid(multi.getParameter("svcId"), 30, 4)); vo.setMakerId(VoV.valid(multi.getParameter("makerId"), 30, 4)); vo.setDevModelId(VoV.valid(multi.getParameter("devModelId"), 30, 4)); vo.setFotaType(VoV.valid(multi.getParameter("fotaType"), 50)); if (!vo.getFotaType().equals("") && !vo.getFotaType().equals("PUSH") && !vo.getFotaType().equals("POLLING") && !vo.getFotaType().equals("PUSHPOLLING")) throw new Exception(); //vo.setFirmwareId(VoV.valid(multi.getParameter("firmwareId"), 30, 4)); //vo.setFirmwareDesc(VoV.valid(multi.getParameter("firmwareDesc"), 1000, 9)); vo.setFirmwareVer(VoV.valid(multi.getParameter("firmwareVer"), 100, 4)); vo.setFirmwareMakerVer(VoV.valid(multi.getParameter("firmwareMakerVer"), 100, 8)); vo.setVerMemo(VoV.valid(multi.getParameter("verMemo"), 1000, 9)); // ? ? String path = DEFAULT_PATH + vo.getDevModelId() + "/"; File pysicalfolder = new File(path); if (!pysicalfolder.exists() || !pysicalfolder.isDirectory()) { pysicalfolder.mkdirs(); } vo.setFilePath(VoV.valid(path, 200)); // ??? File destFile = new File(path + upfile.getName()); if (destFile.exists()) { destFile.delete(); } FileUtils.moveFile(upfile, destFile); //CRC, '0' vo.setCrc("0"); vo.setCretNm(((UserLoginVO) request.getSession().getAttribute("userInfo")).getUserNm()); } catch (Exception e) { // ?? // ??? ? ? if (upfile != null && upfile.exists()) { upfile.delete(); } String errorMSG = e.getMessage(); if (errorMSG.indexOf("exceeds") != 0) { model.addAttribute("error", "?? 500MB ?."); } logger.info("File update error : " + errorMSG); response.setStatus(500); return new ModelAndView(ajaxMainView, model); } mySVC.regi(vo); now = new Date(); logger.info("File update end : " + now.toString()); // Runtime.getRuntime().exec("sudo umount /home/jboss/firmware"); // logger.warn("Firmware Regist - File Upload end... " // + "( Mount Off : sudo umount /home/jboss/firmware )"); return new ModelAndView(ajaxMainView, model); }
From source file:com.dattasmoon.pebble.plugin.FireReceiver.java
@Override public void onReceive(final Context context, final Intent intent) { if (com.twofortyfouram.locale.Intent.ACTION_FIRE_SETTING.equals(intent.getAction())) { // fetch this for later, we may need it in case we change things // around and we need to know what version of the code they were // running when they saved the action int bundleVersionCode = intent.getIntExtra(Constants.BUNDLE_EXTRA_INT_VERSION_CODE, 1); Type type = Type.values()[intent.getIntExtra(Constants.BUNDLE_EXTRA_INT_TYPE, Type.NOTIFICATION.ordinal())]; PowerManager pm;// ww w . jav a2s.c o m switch (type) { case NOTIFICATION: SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context); // handle screen DND boolean notifScreenOn = sharedPref.getBoolean(Constants.PREFERENCE_NOTIF_SCREEN_ON, true); pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); if (Constants.IS_LOGGABLE) { Log.d(Constants.LOG_TAG, "FireReceiver.onReceive: notifScreenOn=" + notifScreenOn + " screen=" + pm.isScreenOn()); } if (!notifScreenOn && pm.isScreenOn()) { break; } //handle quiet hours DND boolean quiet_hours = sharedPref.getBoolean(Constants.PREFERENCE_QUIET_HOURS, false); //we only need to pull this if quiet hours are enabled. Save the cycles for the cpu! (haha) if (quiet_hours) { String[] pieces = sharedPref.getString(Constants.PREFERENCE_QUIET_HOURS_BEFORE, "00:00") .split(":"); Date quiet_hours_before = new Date(0, 0, 0, Integer.parseInt(pieces[0]), Integer.parseInt(pieces[1])); pieces = sharedPref.getString(Constants.PREFERENCE_QUIET_HOURS_AFTER, "23:59").split(":"); Date quiet_hours_after = new Date(0, 0, 0, Integer.parseInt(pieces[0]), Integer.parseInt(pieces[1])); Calendar c = Calendar.getInstance(); Date now = new Date(0, 0, 0, c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE)); if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Checking quiet hours. Now: " + now.toString() + " vs " + quiet_hours_before.toString() + " and " + quiet_hours_after.toString()); } if (now.before(quiet_hours_before) || now.after(quiet_hours_after)) { if (Constants.IS_LOGGABLE) { Log.i(Constants.LOG_TAG, "Time is before or after the quiet hours time. Returning."); } break; } } String title = intent.getStringExtra(Constants.BUNDLE_EXTRA_STRING_TITLE); String body = intent.getStringExtra(Constants.BUNDLE_EXTRA_STRING_BODY); sendAlertToPebble(context, bundleVersionCode, title, body); break; case SETTINGS: Mode mode = Mode.values()[intent.getIntExtra(Constants.BUNDLE_EXTRA_INT_MODE, Mode.OFF.ordinal())]; String packageList = intent.getStringExtra(Constants.BUNDLE_EXTRA_STRING_PACKAGE_LIST); setNotificationSettings(context, bundleVersionCode, mode, packageList); break; } } }
From source file:com.mothsoft.alexis.engine.numeric.TopicActivityDataSetImporter.java
private BigInteger importTopicDataForTopic(final Long topicId, final Date startDate, final Date endDate) { logger.debug(String.format("Importing topic activity for topic: %d between %s and %s", topicId, startDate.toString(), endDate.toString())); final String queryString = "SELECT DATE_FORMAT(td.creation_date, '%Y-%m-%d %H:00:00') as the_hour, " + " COUNT(td.id) from topic_document td INNER JOIN topic on topic.id = td.topic_id " + " WHERE td.creation_date >= ? AND td.creation_date <= ? AND td.topic_id = ? " + " GROUP BY the_hour ORDER BY td.creation_date"; final BigInteger count = this.transactionTemplate.execute(new TransactionCallback<BigInteger>() { @Override/* w w w. ja v a 2 s . c om*/ public BigInteger doInTransaction(TransactionStatus txStatus) { final Query query = TopicActivityDataSetImporter.this.em.createNativeQuery(queryString); query.setParameter(1, startDate); query.setParameter(2, endDate); query.setParameter(3, topicId); final List<?> results = query.getResultList(); if (results == null || results.isEmpty()) { return BigInteger.ZERO; } else { final Object[] array = (Object[]) results.get(0); return (BigInteger) array[1]; } } }); logger.debug("Data set point: (" + startDate + ", " + count + ")"); this.transactionTemplate.execute(new TransactionCallbackWithoutResult() { @Override protected void doInTransactionWithoutResult(TransactionStatus status) { TopicActivityDataSet dataSet = TopicActivityDataSetImporter.this.dataSetDao .findTopicActivityDataSet(topicId); if (dataSet == null) { final DataSetType type = TopicActivityDataSetImporter.this.dataSetTypeDao .findSystemDataSetType(DataSetType.TOPIC_ACTIVITY); final Topic topic = TopicActivityDataSetImporter.this.topicDao.get(topicId); dataSet = new TopicActivityDataSet(topic, type); TopicActivityDataSetImporter.this.em.persist(dataSet); } final DataSetPoint point = new DataSetPoint(dataSet, startDate, count.doubleValue()); TopicActivityDataSetImporter.this.dataSetPointDao.add(point); } }); return count; }
From source file:com.searchbox.collection.oppfin.EENCollection.java
public ItemReader<Profile> reader() throws RemoteException { return new ItemReader<Profile>() { IPODServiceSOAPProxy eenService; ProfileQueryRequest request;/*ww w . ja v a 2 s .com*/ List<Profile> profiles; Date date = new Date(System.currentTimeMillis()); Date start = new Date(System.currentTimeMillis()); DateFormat dfmt = new DateFormatManager("YYYYMMdd").getDateFormatInstance(); { // Get the service eenService = new IPODServiceSOAPProxy(); // Set the password request = new ProfileQueryRequest(); request.setUsername(env.getProperty(EEN_SERVICE_USER, EEN_SERVICE_USER_DEFAULT)); request.setPassword(env.getProperty(EEN_SERVICE_PWD, EEN_SERVICE_PWD_DEFAULT)); // Start with an empty list of profiles profiles = new ArrayList<Profile>(); date = start; } public void fillProfiles(Date from, Date to) { try { LOGGER.info("Fill Profile - ", from.toString(), to.toString()); // time to get some new profiles... JAXBElement<String> jaxbDeadlineDateAfter = new JAXBElement(new QName( "http://schemas.datacontract.org/2004/07/EEN.Merlin.Backend.Core.BO.PODService", "DeadlineDateAfter"), String.class, dfmt.format(from)); JAXBElement<String> jaxbDeadlineDateBefore = new JAXBElement(new QName( "http://schemas.datacontract.org/2004/07/EEN.Merlin.Backend.Core.BO.PODService", "DeadlineDateBefore"), String.class, dfmt.format(to)); request.setDeadlineDateAfter(jaxbDeadlineDateAfter); request.setDeadlineDateBefore(jaxbDeadlineDateBefore); Profile[] newProfiles = eenService.getProfiles(request); EENCollection.LOGGER.info("adding: " + newProfiles.length + " new profiles"); profiles.addAll(Arrays.asList(newProfiles)); } catch (Exception e) { LOGGER.error("Could not load profiles: " + e); } } public Profile read() throws RemoteException { if (start.after(DateUtils.addYears(date, 3))) { return null; } if (profiles.isEmpty()) { while (start.before(DateUtils.addYears(date, 1)) && profiles.isEmpty()) { Date end = DateUtils.addDays(start, 5); EENCollection.LOGGER.info("Fetching EEN profiles from deadline date " + dfmt.format(start) + " to deadline date" + dfmt.format(end)); fillProfiles(start, end); start = end; } if (start.after(DateUtils.addYears(date, 3))) { return null; } } if (profiles.size() == 0) { return null; } return profiles.remove(0); } }; }