List of usage examples for java.text DateFormat MEDIUM
int MEDIUM
To view the source code for java.text DateFormat MEDIUM.
Click Source Link
From source file:Main.java
public static String createDatestring(long timestamp) { if (timestamp == 0) { return ""; }/*from ww w . j a va 2 s . 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 stringFromDateTime(Date dateTime) throws ParseException { String dateTimeString;//from w w w . ja va2 s. c o m DateFormat dateFormatter; dateFormatter = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.getDefault()); dateTimeString = dateFormatter.format(dateTime); return dateTimeString; }
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:Main.java
public static void printDate(Locale locale, Date date) { DateFormat formatter = DateFormat.getDateInstance(DateFormat.SHORT, locale); String formattedDate = formatter.format(date); System.out.println("SHORT: " + formattedDate); formatter = DateFormat.getDateInstance(DateFormat.MEDIUM, locale); formattedDate = formatter.format(date); System.out.println("MEDIUM: " + formattedDate + "\n"); }
From source file:Main.java
public static String DateMessage(Date d, Context c) { DateFormat df = DateFormat.getDateTimeInstance(); DateFormat dfS = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); DateFormat dfM = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM); DateFormat dfL = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG); DateFormat dfF = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL); DateFormat dfNoTime = DateFormat.getDateInstance(); DateFormat dfSNoTime = DateFormat.getDateInstance(DateFormat.SHORT, Locale.ENGLISH); DateFormat dfMNoTime = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.ENGLISH); DateFormat dfLNoTime = DateFormat.getDateInstance(DateFormat.LONG, Locale.ENGLISH); DateFormat dfFNoTime = DateFormat.getDateInstance(DateFormat.FULL, Locale.ENGLISH); DateFormat dfDevice = android.text.format.DateFormat.getDateFormat(c); String s = dfDevice.format(d) + " or \n" + dfS.format(d) + " or \n" + dfM.format(d) + " or \n" + dfL.format(d) + " or \n" + dfF.format(d); return s;/*w ww . j a v a2 s . com*/ }
From source file:Main.java
public static Date FormatDate(String sRecDate, Context c) { DateFormat df = DateFormat.getDateTimeInstance(); DateFormat dfS = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); DateFormat dfM = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM); DateFormat dfL = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG); DateFormat dfF = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL); DateFormat dfNoTime = DateFormat.getDateInstance(); DateFormat dfSNoTime = DateFormat.getDateInstance(DateFormat.SHORT, Locale.ENGLISH); DateFormat dfMNoTime = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.ENGLISH); DateFormat dfLNoTime = DateFormat.getDateInstance(DateFormat.LONG, Locale.ENGLISH); DateFormat dfFNoTime = DateFormat.getDateInstance(DateFormat.FULL, Locale.ENGLISH); DateFormat dfDevice = android.text.format.DateFormat.getDateFormat(c); Date dRecDate = null;/*w ww . jav a2 s .co m*/ try { dRecDate = dfDevice.parse(sRecDate); } catch (ParseException e) { try { dRecDate = df.parse(sRecDate); } catch (ParseException e2) { try { dRecDate = dfS.parse(sRecDate); } catch (ParseException e3) { try { dRecDate = dfM.parse(sRecDate); } catch (ParseException e4) { try { dRecDate = dfL.parse(sRecDate); } catch (ParseException e5) { try { dRecDate = dfF.parse(sRecDate); } catch (ParseException e6) { try { dRecDate = dfNoTime.parse(sRecDate); } catch (ParseException e7) { try { dRecDate = dfSNoTime.parse(sRecDate); } catch (ParseException e8) { try { dRecDate = dfMNoTime.parse(sRecDate); } catch (ParseException e9) { try { dRecDate = dfLNoTime.parse(sRecDate); } catch (ParseException e10) { try { dRecDate = dfFNoTime.parse(sRecDate); } catch (ParseException e11) { } } } } } } } } } } } return dRecDate; }
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.vityuk.ginger.provider.format.JdkDateUtils.java
private static int createJdkDateStyleCode(DateFormatStyle formatStyle) { switch (formatStyle) { case SHORT:// w w w .j a v a 2 s . c om return DateFormat.SHORT; case MEDIUM: return DateFormat.MEDIUM; case LONG: return DateFormat.LONG; case FULL: return DateFormat.FULL; case DEFAULT: return DateFormat.DEFAULT; default: throw new IllegalArgumentException(); } }