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.gst.infrastructure.core.api.JsonCommand.java
public boolean isChangeInTimeParameterNamed(final String parameterName, final Date existingValue, final String timeFormat) { LocalDateTime time = null;/*from w w w . ja v a 2s. c om*/ if (existingValue != null) { DateTimeFormatter timeFormtter = DateTimeFormat.forPattern(timeFormat); time = LocalDateTime.parse(existingValue.toString(), timeFormtter); } return isChangeInLocalTimeParameterNamed(parameterName, time); }
From source file:com.mycompany.jpegrenamer.MetaDataReader.java
public Map<String, String> getMetaData(final File jpegImageFile) throws ImageProcessingException, IOException { Metadata metadata = ImageMetadataReader.readMetadata(jpegImageFile); Map<String, String> res = new HashMap<>(); res.put("date", "Pinding"); for (Directory directory : metadata.getDirectories()) { for (Tag tag : directory.getTags()) { logger.debug("{} - {} = {}", directory.getName(), tag.getTagName(), tag.getDescription()); }/*from ww w .jav a 2 s . c o m*/ if (directory.hasErrors()) { for (String error : directory.getErrors()) { logger.debug("ERROR: {}", error); } } } // obtain the Exif directory ExifSubIFDDirectory directory = metadata.getFirstDirectoryOfType(ExifSubIFDDirectory.class); // query the tag's value if (directory == null) { return res; } PanasonicMakernoteDirectory pmd = metadata.getFirstDirectoryOfType(PanasonicMakernoteDirectory.class); if (pmd != null) { String country = ""; String city = ""; String landmark = ""; for (Tag tag : pmd.getTags()) { if (tag.getTagType() == PanasonicMakernoteDirectory.TAG_COUNTRY) { country = tag.getDescription(); if (!country.equals("---")) { res.put("country", country); } } else if (tag.getTagType() == PanasonicMakernoteDirectory.TAG_CITY) { city = tag.getDescription(); if (!city.equals("---")) { res.put("locality", city); } } else if (tag.getTagType() == PanasonicMakernoteDirectory.TAG_LANDMARK) { landmark = tag.getDescription(); if (!landmark.equals("---")) { res.put("premise", landmark); } } } logger.info("Panasonic fafa " + country + " x " + city + " x " + landmark); } Date dateOfCapture = directory.getDate(ExifSubIFDDirectory.TAG_DATETIME_ORIGINAL); final DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH.mm.ss", Locale.ENGLISH); String s = null; if (dateOfCapture != null) { s = df.format(dateOfCapture); } else { return res; } logger.info("Date " + dateOfCapture.toString()); logger.info("Date f " + s); res.put("date", s); // if (res.get("country") != null) { // // We have some data from Panasonic Makernotes, so no need to lookup GPS // return res; // } // See whether it has GPS data Collection<GpsDirectory> gpsDirectories = metadata.getDirectoriesOfType(GpsDirectory.class); if (gpsDirectories == null) { return res; } for (GpsDirectory gpsDirectory : gpsDirectories) { // Try to read out the location, making sure it's non-zero GeoLocation geoLocation = gpsDirectory.getGeoLocation(); if (geoLocation != null && !geoLocation.isZero()) { // Add to our collection for use below logger.info("Geo " + geoLocation.toString()); double lat = geoLocation.getLatitude(); double lon = geoLocation.getLongitude(); Locale fmtLocale = Locale.US; NumberFormat formatter = NumberFormat.getNumberInstance(fmtLocale); formatter.setGroupingUsed(false); Map<String, String> location = new HashMap(); ; try { location = getAddressByGpsCoordinates(formatter.format(lat), formatter.format(lon)); logger.info("Location " + location); res.putAll(location); } catch (MalformedURLException ex) { logger.error("", ex); } catch (org.json.simple.parser.ParseException ex) { logger.error("", ex); } break; } } return res; }
From source file:org.dvbviewer.controller.ui.fragments.ChannelEpg.java
/** * Cursor to timer.//from www . ja v a2s . co m * * @param c the c * @return the timer * @author RayBa * @date 07.04.2013 */ private Timer cursorToTimer(Cursor c) { String name = mCHannel.getName(); long channelID = mCHannel.getId(); String epgTitle = !c.isNull(c.getColumnIndex(EpgTbl.TITLE)) ? c.getString(c.getColumnIndex(EpgTbl.TITLE)) : name; long epgStart = c.getLong(c.getColumnIndex(EpgTbl.START)); long epgEnd = c.getLong(c.getColumnIndex(EpgTbl.END)); DVBViewerPreferences prefs = new DVBViewerPreferences(getSherlockActivity()); int epgBefore = prefs.getPrefs().getInt(DVBViewerPreferences.KEY_TIMER_TIME_BEFORE, 5); int epgAfter = prefs.getPrefs().getInt(DVBViewerPreferences.KEY_TIMER_TIME_AFTER, 5); Date start = epgStart > 0 ? new Date(epgStart) : new Date(); Date end = epgEnd > 0 ? new Date(epgEnd) : new Date(); Log.i(ChannelList.class.getSimpleName(), start.toString()); Log.i(ChannelList.class.getSimpleName(), start.toString()); Log.i(ChannelList.class.getSimpleName(), start.toString()); start = DateUtils.addMinutes(start, 0 - epgBefore); end = DateUtils.addMinutes(end, epgAfter); Timer timer = new Timer(); timer.setTitle(epgTitle); timer.setChannelId(channelID); timer.setChannelName(name); timer.setStart(start); timer.setEnd(end); timer.setTimerAction(prefs.getPrefs().getInt(DVBViewerPreferences.KEY_TIMER_DEF_AFTER_RECORD, 0)); return timer; }
From source file:com.googlecode.gmail4j.test.imap.ImapGmailClientTest.java
/** * Tests retrieval of messages by date//from w ww.j a v a2s . c o m */ @Test public void testGetMessagesByDateGreaterThan() { final ImapGmailClient client = new ImapGmailClient(ImapGmailLabel.SENT_MAIL); final ImapGmailConnection connection = new ImapGmailConnection(); try { connection.setLoginCredentials(conf.getGmailCredentials()); if (conf.useProxy()) { connection.setProxy(conf.getProxyHost(), conf.getProxyPort()); connection.setProxyCredentials(conf.getProxyCredentials()); } Date date = new Date(); Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.add(Calendar.DATE, -1); date = cal.getTime(); log.debug("Getting messages newer than yesterday" + date.toString()); client.setConnection(connection); final List<GmailMessage> messages = client.getMessagesBy(GmailClient.EmailSearchStrategy.DATE_GT, date.toString()); for (GmailMessage message : messages) { log.debug(message); } assertNotNull("Messages are not null", messages); } catch (final Exception e) { log.error("Test Failed", e); fail("Caught exception: " + e.getMessage()); } finally { client.disconnect(); } }
From source file:com.silverpeas.silvercrawler.control.SilverCrawlerSessionController.java
public void unindexPath(String folderName) { SilverTrace.info("silverCrawler", "SilverCrawlerSessionController.unindexPath()", "root.MSG_GEN_ENTER_METHOD", "folderName = " + folderName); RepositoryIndexer repositoryIndexer = new RepositoryIndexer(getSpaceId(), getComponentId()); String pathRepository = getFullPath(folderName); Date date = new Date(); repositoryIndexer.pathIndexer(pathRepository, date.toString(), getUserId(), "remove"); }
From source file:com.silverpeas.silvercrawler.control.SilverCrawlerSessionController.java
public void indexPath(String folderName) { SilverTrace.info("silverCrawler", "SilverCrawlerSessionController.indexPath()", "root.MSG_GEN_ENTER_METHOD", "folderName = " + folderName); RepositoryIndexer repositoryIndexer = new RepositoryIndexer(getSpaceId(), getComponentId()); String pathRepository = getFullPath(folderName); Date date = new Date(); repositoryIndexer.pathIndexer(pathRepository, date.toString(), getUserId(), "add"); }
From source file:gov.utah.dts.sdc.actions.BaseThirdPartyStudentAction.java
public String insertTrainingTime() throws Exception { log.debug("insertTrainingTime"); //log.debug("observationDate truncated "+ truncateDate(getObservationDate())); int start = decodeTime(trainingStartTime); Date startDate = new Date(getTrainingDate().getTime() + start); log.debug("startDate " + startDate.toString()); int end = decodeTime(trainingEndTime); Date endDate = new Date(getTrainingDate().getTime() + end); log.debug("endDate " + endDate.toString()); if (endDate.before(startDate)) { addActionError("Start Time Must Be Before End Time"); } else {//w ww .j a v a 2 s . c om Map<String, Object> hm = new HashMap<String, Object>(); hm.put("trainingStartTime", startDate); hm.put("trainingEndTime", endDate); hm.put("section", section); hm.put("vehicleFk", vehicleFk); hm.put("instructorFk", instructorFk); hm.put("classroomFk", classroomPk); hm.put("branchFk", branchFk); for (int x = 0; x < studentArray.size(); x++) { hm.put("studentFk", studentArray.get(x)); getStudentService().insertTraining(hm); } } if (hasErrors()) { return INPUT; } else { StringBuffer sb = new StringBuffer(); sb.append("<br/>Training Times Added For "); sb.append(studentArray.size()); if (studentArray.size() == 1) { sb.append(" Student"); } else { sb.append(" Students"); } Collection<Object> col = new ArrayList<Object>(); col.add(sb); setThirdPartyAjaxMessages(col); return SUCCESS; } }
From source file:gov.utah.dts.sdc.actions.BaseThirdPartyStudentAction.java
public String insertObservationTime() throws Exception { log.debug("insertObservationTime"); //log.debug("observationDate truncated "+ truncateDate(getObservationDate())); int start = decodeTime(observationStartTime); Date startDate = new Date(getObservationDate().getTime() + start); log.debug("startDate " + startDate.toString()); int end = decodeTime(observationEndTime); Date endDate = new Date(getObservationDate().getTime() + end); log.debug("endDate " + endDate.toString()); if (endDate.before(startDate)) { addActionError("Start Time Must Be Before End Time"); } else {// ww w . j a va2s . c o m Map<String, Object> hm = new HashMap<String, Object>(); hm.put("observationStartTime", startDate); hm.put("observationEndTime", endDate); hm.put("vehicleFk", vehicleFk); hm.put("instructorFk", instructorFk); hm.put("classroomFk", classroomPk); hm.put("branchFk", branchFk); for (int x = 0; x < studentArray.size(); x++) { hm.put("studentFk", studentArray.get(x)); getStudentService().insertObservation(hm); } } if (hasErrors()) { return INPUT; } else { StringBuffer sb = new StringBuffer(); sb.append("<br/>Observation Times Added For "); sb.append(studentArray.size()); if (studentArray.size() == 1) { sb.append(" Student"); } else { sb.append(" Students"); } Collection<Object> col = new ArrayList<Object>(); col.add(sb); setThirdPartyAjaxMessages(col); return SUCCESS; } }
From source file:gov.utah.dts.sdc.actions.BaseThirdPartyStudentAction.java
public String insertBtwTime() throws Exception { log.debug("insertBtwTime"); //log.debug("observationDate truncated "+ truncateDate(getObservationDate())); int start = decodeTime(behindTheWheelStartTime); Date startDate = new Date(getBehindTheWheelDate().getTime() + start); log.debug("startDate " + startDate.toString()); int end = decodeTime(behindTheWheelEndTime); Date endDate = new Date(getBehindTheWheelDate().getTime() + end); log.debug("endDate " + endDate.toString()); if (endDate.before(startDate)) { addActionError("Start Time Must Be Before End Time"); } else {//w w w.j ava 2 s . c om Map<String, Object> hm = new HashMap<String, Object>(); hm.put("btwStartTime", startDate); hm.put("btwEndTime", endDate); hm.put("vehicleFk", vehicleFk); hm.put("instructorFk", instructorFk); hm.put("classroomFk", classroomPk); hm.put("branchFk", branchFk); for (int x = 0; x < studentArray.size(); x++) { hm.put("studentFk", studentArray.get(x)); getStudentService().insertBehindTheWheel(hm); } } if (hasErrors()) { return INPUT; } else { StringBuffer sb = new StringBuffer(); sb.append("<br/>Behind The Wheel Times Added For "); sb.append(studentArray.size()); if (studentArray.size() == 1) { sb.append(" Student"); } else { sb.append(" Students"); } Collection<Object> col = new ArrayList<Object>(); col.add(sb); setThirdPartyAjaxMessages(col); return SUCCESS; } }