List of usage examples for java.text DateFormat getDateTimeInstance
public static final DateFormat getDateTimeInstance(int dateStyle, int timeStyle)
From source file:Main.java
public static String getPrettyDateTime(Calendar date) { DateFormat dateTimeFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT); return dateTimeFormat.format(date.getTime()); }
From source file:Main.java
public static String createDatestring(long timestamp) { if (timestamp == 0) { return ""; }//from w ww . j a va 2s . c o m DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM); return df.format(new Date(timestamp)); }
From source file:Main.java
public static String dateTimeFormat(Date date, int dateFormat, int timeFormat) { DateFormat dateFormat1 = DateFormat.getDateTimeInstance(dateFormat, timeFormat); return dateFormat1.format(date); }
From source file:Main.java
public static String formatDate(Date d) { return DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM).format(d); }
From source file:Main.java
public static Date parseDate(String s) throws ParseException { return DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM).parse(s); }
From source file:Main.java
public static DateFormat getDateFormat(final boolean seconds) { return DateFormat.getDateTimeInstance(DateFormat.MEDIUM, seconds ? DateFormat.MEDIUM : DateFormat.SHORT); }
From source file:DateUtils.java
/** * A method to get the current date and time to use in a timestamp * * @return a string containing the timestamp *///w w w. ja v a 2 s.c o m public static String getCurrentDateAndTime() { GregorianCalendar calendar = new GregorianCalendar(); DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL); return formatter.format(calendar.getTime()); }
From source file:org.exoplatform.wcm.webui.search.UISearchResult.java
/** * Gets the mofified date of search result node. * * @param node the node/*from www.j a v a2 s . c o m*/ * @return the mofified date * @throws Exception the exception */ private String getModifiedDate(Node node) throws Exception { Calendar calendar = node.hasProperty(NodetypeConstant.EXO_LAST_MODIFIED_DATE) ? node.getProperty(NodetypeConstant.EXO_LAST_MODIFIED_DATE).getDate() : node.getProperty(NodetypeConstant.EXO_DATE_CREATED).getDate(); DateFormat simpleDateFormat = SimpleDateFormat.getDateTimeInstance(SimpleDateFormat.FULL, SimpleDateFormat.SHORT); return simpleDateFormat.format(calendar.getTime()); }
From source file:SessionDisplay.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException { response.setContentType("text/html"); java.io.PrintWriter out = response.getWriter(); HttpSession session = request.getSession(); Date creationTime = new Date(session.getCreationTime()); Date lastAccessed = new Date(session.getLastAccessedTime()); Date now = new Date(); DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM); out.println("<html>"); out.println("<head>"); out.println("<title>Displaying the Session Creation and Last-Accessed Time</title>"); out.println("</head>"); out.println("<body>"); out.println("<h2>Session Creation and Last-Accessed Time</h2>"); out.println("The time and date now is: " + formatter.format(now) + "<br><br>"); out.println("The session creation time: HttpSession.getCreationTime( ): " + formatter.format(creationTime) + "<br><br>"); out.println("The last time the session was accessed: HttpSession.getLastAccessedTime( ): " + formatter.format(lastAccessed)); out.println("</body>"); out.println("</html>"); }
From source file:com.joshlong.esb.springintegration.modules.social.twitter.test.TwitterProducer.java
public String tweet() { Date d = new Date(); DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); return String.format("The time is %s and all is well!", dateFormat.format(d)); }