List of usage examples for java.util Date toString
public String toString()
where:dow mon dd hh:mm:ss zzz yyyy
From source file:uidmsgshow.java
public static void dumpEnvelope(Message m) throws Exception { System.out.println("This is the message envelope"); System.out.println("---------------------------"); Address[] a;/*from w ww.j a v a2 s. c o m*/ // FROM if ((a = m.getFrom()) != null) { for (int j = 0; j < a.length; j++) System.out.println("FROM: " + a[j].toString()); } // TO if ((a = m.getRecipients(Message.RecipientType.TO)) != null) { for (int j = 0; j < a.length; j++) System.out.println("TO: " + a[j].toString()); } // SUBJECT System.out.println("SUBJECT: " + m.getSubject()); // DATE Date d = m.getSentDate(); System.out.println("SendDate: " + (d != null ? d.toString() : "UNKNOWN")); // SIZE System.out.println("Size: " + m.getSize()); // FLAGS: Flags flags = m.getFlags(); StringBuffer sb = new StringBuffer(); Flags.Flag[] sf = flags.getSystemFlags(); // get the system flags boolean first = true; for (int i = 0; i < sf.length; i++) { String s; Flags.Flag f = sf[i]; if (f == Flags.Flag.ANSWERED) s = "\\Answered"; else if (f == Flags.Flag.DELETED) s = "\\Deleted"; else if (f == Flags.Flag.DRAFT) s = "\\Draft"; else if (f == Flags.Flag.FLAGGED) s = "\\Flagged"; else if (f == Flags.Flag.RECENT) s = "\\Recent"; else if (f == Flags.Flag.SEEN) s = "\\Seen"; else continue; // skip it if (first) first = false; else sb.append(' '); sb.append(s); } String[] uf = flags.getUserFlags(); // get the user flag strings for (int i = 0; i < uf.length; i++) { if (first) first = false; else sb.append(' '); sb.append(uf[i]); } System.out.println("FLAGS = " + sb.toString()); // X-MAILER String[] hdrs = m.getHeader("X-Mailer"); if (hdrs != null) System.out.println("X-Mailer: " + hdrs[0]); else System.out.println("X-Mailer NOT available"); }
From source file:uidmsgshow.java
public static void dumpEnvelope(Message m) throws Exception { System.out.println("This is the message envelope"); System.out.println("---------------------------"); Address[] a;/*from w w w . j a v a 2s . c o m*/ // FROM if ((a = m.getFrom()) != null) { for (int j = 0; j < a.length; j++) System.out.println("FROM: " + a[j].toString()); } // TO if ((a = m.getRecipients(Message.RecipientType.TO)) != null) { for (int j = 0; j < a.length; j++) System.out.println("TO: " + a[j].toString()); } // SUBJECT System.out.println("SUBJECT: " + m.getSubject()); // DATE Date d = m.getSentDate(); System.out.println("SendDate: " + (d != null ? d.toString() : "UNKNOWN")); // SIZE System.out.println("Size: " + m.getSize()); // FLAGS: Flags flags = m.getFlags(); StringBuffer sb = new StringBuffer(); Flags.Flag[] sf = flags.getSystemFlags(); // get the system flags boolean first = true; for (int i = 0; i < sf.length; i++) { String s; Flags.Flag f = sf[i]; if (f == Flags.Flag.ANSWERED) s = "\\Answered"; else if (f == Flags.Flag.DELETED) s = "\\Deleted"; else if (f == Flags.Flag.DRAFT) s = "\\Draft"; else if (f == Flags.Flag.FLAGGED) s = "\\Flagged"; else if (f == Flags.Flag.RECENT) s = "\\Recent"; else if (f == Flags.Flag.SEEN) s = "\\Seen"; else continue; // skip it if (first) first = false; else sb.append(' '); sb.append(s); } String[] uf = flags.getUserFlags(); // get the user flag strings for (int i = 0; i < uf.length; i++) { if (first) first = false; else sb.append(' '); sb.append(uf[i]); } System.out.println("FLAGS = " + sb.toString()); // X-MAILER String[] hdrs = m.getHeader("X-Mailer"); if (hdrs != null) System.out.println("X-Mailer: " + hdrs[0]); else System.out.println("X-Mailer NOT available"); }
From source file:com.twinsoft.convertigo.engine.util.CookiesUtils.java
public static void addCookie(HttpState httpState, String domain, String name, String value, String path, Date expires, boolean secure) { Cookie cookie = null;//from w w w.j a v a 2 s.c o m try { Engine.logBeans.debug(String.format( "(CookiesUtils) Adding cookie: " + "domain=%s, name=%s, value=%s, path=%s, expires=%s, secure=%s", domain, name, value, path, expires.toString(), Boolean.toString(secure))); cookie = new Cookie(domain, name, value, path, expires, secure); if (cookie != null) { Engine.logBeans.debug("(CookiesUtils) added cookie: " + cookie); httpState.addCookie(cookie); } } catch (Exception e) { Engine.logBeans.debug("(CookiesUtils) failed to parse cookie: " + cookie); } }
From source file:de.ingrid.portal.global.UtilsFileHelper.java
public static HashMap<String, String> getInstallVersion(String path, String title) { HashMap<String, String> versionMap = new HashMap<String, String>(); BufferedReader bufferReader;//www. jav a 2 s .c o m try { bufferReader = new BufferedReader(new FileReader(path)); String input = ""; while ((input = bufferReader.readLine()) != null) { if (input.startsWith("Implementation-Build")) { String value = input.split(":")[1].trim(); if (value.length() > 0) { versionMap.put("svn_version", value); } } else if (input.startsWith("Implementation-Version")) { String value = input.split(":")[1].trim(); if (value.length() > 0) { versionMap.put("project_version", value); } } else if (input.startsWith("Build-Timestamp")) { String value = input.split(":")[1].trim(); if (value.length() > 0) { Date date = new Date(Long.valueOf(value)); versionMap.put("build_time", date.toString()); } } } } catch (IOException e) { log.error("File not found: " + path); } if (versionMap.size() > 0) { versionMap.put("title", title); } return versionMap; }
From source file:com.pearson.openideas.cq5.components.utils.ArticleUtils.java
/** * This method turns a tagged resource into an article object. * //from w w w.j a va2 s . c om * @param resource * the resource to extract data from * @param article * the article object to add data to * @param tagManager * the tag manager instance * @param indexing * A boolean to indicate whether to include the indexing fields or not. * @return the completed/populated article object */ public static Article createArticleObject(Resource resource, Article article, TagManager tagManager, boolean indexing) { List<String> countries = new ArrayList<String>(); List<String> contributors = new ArrayList<String>(); List<String> organisations = new ArrayList<String>(); List<String> keywords = new ArrayList<String>(); List<String> contributorBiogs = new ArrayList<String>(); log.debug("Are we indexing? " + indexing); Calendar weekAgo = Calendar.getInstance(); weekAgo.set(weekAgo.get(Calendar.YEAR), weekAgo.get(Calendar.MONTH), weekAgo.get(Calendar.DAY_OF_MONTH) - BEFOREDAYS); String path = resource.getPath(); log.debug("path to resource: " + path); article.setUrl(StringUtils.substring(path, 0, path.lastIndexOf("/"))); ValueMap articleMap = resource.getChild("articleBody").adaptTo(ValueMap.class); article.setShortSummary(articleMap.get("shortsummary", "")); article.setArticleTitle(articleMap.get("articletitle", "")); //pull the image from the article Image image = new Image(resource.getChild("articleBody").getChild("image")); image.setSelector(".img"); article.setImage(image); //also, pull the thumbnail image from the article if (resource.getChild("articleBody").getChild("imagethumb") != null) { Image thumbnail = new Image(resource.getChild("articleBody").getChild("imagethumb")); thumbnail.setSelector(".img"); log.debug("article thumbnail has an image: " + thumbnail.hasContent()); article.setThumbnail(thumbnail); } else { log.debug("no thumbnail, falling back to article image"); article.setThumbnail(image); } // second, we'll pull the contributor tags from however many contributor components we have Resource leadContribResource = resource.getChild("leadContributor"); // pull an array of one to get the lead contributor name for rendering Tag[] leadContribTags = tagManager.getTags(leadContribResource); if (leadContribTags != null && leadContribTags.length > 0) { article.setAuthor(leadContribTags[0].getTitle()); } else { log.warn("Article " + article.getArticleTitle() + "has no lead contributor set yet."); } if (StringUtils.isNotBlank(articleMap.get("newpublishdate", ""))) { Date newPubDateObject = null; SimpleDateFormat sdf = new SimpleDateFormat(DateFormatEnum.CQDATEFORMAT.getDateFormat()); try { newPubDateObject = sdf.parse(articleMap.get("newpublishdate", "")); } catch (ParseException e) { log.error("Error parsing date", e); } if (newPubDateObject != null) { String newDateString = new SimpleDateFormat(DateFormatEnum.CLIENTDATEFORMAT.getDateFormat()) .format(newPubDateObject); article.setPubDate(newDateString); article.setPubDateObject(newPubDateObject); if (newPubDateObject.after(weekAgo.getTime())) { article.setSuitableForEmail(true); } } else { log.warn("new pub date object is null"); } } else { log.debug("Trying to parse original date object"); Date originalPubDateObject = resource.adaptTo(ValueMap.class).get("jcr:created", Date.class); log.debug("original pub date: " + originalPubDateObject.toString()); String originalPublishDateString = new SimpleDateFormat(DateFormatEnum.CLIENTDATEFORMAT.getDateFormat()) .format(originalPubDateObject); article.setPubDate(originalPublishDateString); article.setPubDateObject(originalPubDateObject); if (originalPubDateObject.after(weekAgo.getTime())) { article.setSuitableForEmail(true); } } Tag[] tags = tagManager.getTags(resource); for (Tag tagFromPage : tags) { String tagPath = tagFromPage.getPath(); if (tagPath.contains(NamespaceEnum.THEME.getNamespace())) { article.setTheme(tagFromPage.getTitle()); } else if (tagPath.contains(NamespaceEnum.CATEGORY.getNamespace())) { article.setCategory(tagFromPage.getTitle()); } else if (indexing && tagPath.contains(NamespaceEnum.CONTRIBUTOR.getNamespace())) { contributors.add(tagFromPage.getTitle()); contributorBiogs.add(tagFromPage.getDescription()); } else if (indexing && tagPath.contains(NamespaceEnum.KEYWORD.getNamespace())) { keywords.add(tagFromPage.getTitle()); } else if (indexing && tagPath.contains(NamespaceEnum.ORGANISATION.getNamespace())) { organisations.add(tagFromPage.getTitle()); } else if (indexing && tagPath.contains(NamespaceEnum.COUNTRY.getNamespace())) { countries.add(tagFromPage.getTitle()); } } if (indexing) { article.setContributors(contributors); article.setCountries(countries); article.setOrganisations(organisations); article.setKeywords(keywords); article.setContributorBiogs(contributorBiogs); article.setCitation(articleMap.get("citation", "")); String articleText = articleMap.get("text", ""); Resource par = resource.getChild("par"); if (par != null) { Iterator<Resource> parResources = par.listChildren(); while (parResources.hasNext()) { Resource parResource = parResources.next(); ValueMap resourceMap = parResource.adaptTo(ValueMap.class); String type = resourceMap.get("sling:resourceType", ""); if (type.endsWith("articleText")) { articleText += resourceMap.get("text", ""); } } } article.setArticleText(articleText); } return article; }
From source file:Main.java
/** * Returns the Date from the long milliseconds * /*from ww w . j a v a 2s .c o m*/ * @param date * in millis * @return {@link String} */ public static String GetDateFromLong(long date) { Date currentDate = new Date(date); DateFormat formatter = new SimpleDateFormat("dd MMM yyyy"); // formatted value of current Date // System.out.println("Milliseconds to Date: " + // formatter.format(currentDate)); Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(date); // System.out.println("Milliseconds to Date using Calendar:" // + formatter.format(cal.getTime())); return currentDate.toString(); }
From source file:msgshow.java
public static void dumpEnvelope(Message m) throws Exception { pr("This is the message envelope"); pr("---------------------------"); Address[] a;// w ww .j ava2 s. c o m // FROM if ((a = m.getFrom()) != null) { for (int j = 0; j < a.length; j++) pr("FROM: " + a[j].toString()); } // REPLY TO if ((a = m.getReplyTo()) != null) { for (int j = 0; j < a.length; j++) pr("REPLY TO: " + a[j].toString()); } // TO if ((a = m.getRecipients(Message.RecipientType.TO)) != null) { for (int j = 0; j < a.length; j++) { pr("TO: " + a[j].toString()); InternetAddress ia = (InternetAddress) a[j]; if (ia.isGroup()) { InternetAddress[] aa = ia.getGroup(false); for (int k = 0; k < aa.length; k++) pr(" GROUP: " + aa[k].toString()); } } } // SUBJECT pr("SUBJECT: " + m.getSubject()); // DATE Date d = m.getSentDate(); pr("SendDate: " + (d != null ? d.toString() : "UNKNOWN")); // FLAGS Flags flags = m.getFlags(); StringBuffer sb = new StringBuffer(); Flags.Flag[] sf = flags.getSystemFlags(); // get the system flags boolean first = true; for (int i = 0; i < sf.length; i++) { String s; Flags.Flag f = sf[i]; if (f == Flags.Flag.ANSWERED) s = "\\Answered"; else if (f == Flags.Flag.DELETED) s = "\\Deleted"; else if (f == Flags.Flag.DRAFT) s = "\\Draft"; else if (f == Flags.Flag.FLAGGED) s = "\\Flagged"; else if (f == Flags.Flag.RECENT) s = "\\Recent"; else if (f == Flags.Flag.SEEN) s = "\\Seen"; else continue; // skip it if (first) first = false; else sb.append(' '); sb.append(s); } String[] uf = flags.getUserFlags(); // get the user flag strings for (int i = 0; i < uf.length; i++) { if (first) first = false; else sb.append(' '); sb.append(uf[i]); } pr("FLAGS: " + sb.toString()); // X-MAILER String[] hdrs = m.getHeader("X-Mailer"); if (hdrs != null) pr("X-Mailer: " + hdrs[0]); else pr("X-Mailer NOT available"); }
From source file:org.apache.cocoon.components.language.markup.xsp.XSPUtil.java
public static String formatDate(Date date, String pattern) { if (StringUtils.isEmpty(pattern)) { pattern = "yyyy/MM/dd hh:mm:ss aa"; }// www . j a va 2 s . c om try { return (new SimpleDateFormat(pattern)).format(date); } catch (Exception e) { return date.toString(); } }
From source file:MainClass.java
public static void dumpEnvelope(Message m) throws Exception { pr("This is the message envelope"); pr("---------------------------"); Address[] a;/*from ww w. ja v a 2 s.c om*/ // FROM if ((a = m.getFrom()) != null) { for (int j = 0; j < a.length; j++) pr("FROM: " + a[j].toString()); } // TO if ((a = m.getRecipients(Message.RecipientType.TO)) != null) { for (int j = 0; j < a.length; j++) { pr("TO: " + a[j].toString()); InternetAddress ia = (InternetAddress) a[j]; if (ia.isGroup()) { InternetAddress[] aa = ia.getGroup(false); for (int k = 0; k < aa.length; k++) pr(" GROUP: " + aa[k].toString()); } } } // SUBJECT pr("SUBJECT: " + m.getSubject()); // DATE Date d = m.getSentDate(); pr("SendDate: " + (d != null ? d.toString() : "UNKNOWN")); // FLAGS Flags flags = m.getFlags(); StringBuffer sb = new StringBuffer(); Flags.Flag[] sf = flags.getSystemFlags(); // get the system flags boolean first = true; for (int i = 0; i < sf.length; i++) { String s; Flags.Flag f = sf[i]; if (f == Flags.Flag.ANSWERED) s = "\\Answered"; else if (f == Flags.Flag.DELETED) s = "\\Deleted"; else if (f == Flags.Flag.DRAFT) s = "\\Draft"; else if (f == Flags.Flag.FLAGGED) s = "\\Flagged"; else if (f == Flags.Flag.RECENT) s = "\\Recent"; else if (f == Flags.Flag.SEEN) s = "\\Seen"; else continue; // skip it if (first) first = false; else sb.append(' '); sb.append(s); } String[] uf = flags.getUserFlags(); // get the user flag strings for (int i = 0; i < uf.length; i++) { if (first) first = false; else sb.append(' '); sb.append(uf[i]); } pr("FLAGS: " + sb.toString()); // X-MAILER String[] hdrs = m.getHeader("X-Mailer"); if (hdrs != null) pr("X-Mailer: " + hdrs[0]); else pr("X-Mailer NOT available"); }
From source file:org.eclipse.jubula.client.cmd.AbstractCmdlineClient.java
/** * writes an output to console/*from ww w . ja v a 2 s. c o m*/ * @param text * Message * @param printTimestamp should a timestamp be printed */ public static void printConsoleLn(String text, boolean printTimestamp) { if (printTimestamp) { Date now = new Date(); String time = now.toString(); printConsole(time); printConsole(StringConstants.TAB); } printConsole(StringUtils.chomp(text)); printConsole(StringConstants.NEWLINE); }