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 void main(String[] argv) throws Exception { Locale locale = Locale.ITALIAN; Date date = new Date(); DateFormat df = DateFormat.getTimeInstance(DateFormat.MEDIUM, locale); String s = df.format(date);/*from w w w . j a va 2s.co m*/ System.out.println(s); }
From source file:MainClass.java
public static void main(String[] args) { DateFormat shortDf = DateFormat.getDateInstance(DateFormat.SHORT); DateFormat mediumDf = DateFormat.getDateInstance(DateFormat.MEDIUM); DateFormat longDf = DateFormat.getDateInstance(DateFormat.LONG); DateFormat fullDf = DateFormat.getDateInstance(DateFormat.FULL); System.out.println(shortDf.format(new Date())); System.out.println(mediumDf.format(new Date())); System.out.println(longDf.format(new Date())); System.out.println(fullDf.format(new Date())); // parsing//from w ww . java2 s . co m try { Date date = shortDf.parse("Jan 32, 2005"); } catch (ParseException e) { } }
From source file:MainClass.java
public static void main(String[] args) { DateFormat shortDf = DateFormat.getDateInstance(DateFormat.SHORT); DateFormat mediumDf = DateFormat.getDateInstance(DateFormat.MEDIUM); DateFormat longDf = DateFormat.getDateInstance(DateFormat.LONG); DateFormat fullDf = DateFormat.getDateInstance(DateFormat.FULL); System.out.println(shortDf.format(new Date())); System.out.println(mediumDf.format(new Date())); System.out.println(longDf.format(new Date())); System.out.println(fullDf.format(new Date())); // parsing// ww w . j a v a 2s . co m try { Date date = shortDf.parse("12/12/2006"); } catch (ParseException e) { } }
From source file:Main.java
public static void main(String[] args) { Date date = new Date(); // Format date in a short format String today = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(date); System.out.println("Today " + today); // Format date in a medium format today = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM).format(date); System.out.println("Today " + today); // Format date in a long format today = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG).format(date); System.out.println("Today " + today); }
From source file:MainClass.java
public static void main(String args[]) { Date date = new Date(); DateFormat df;/*ww w. j a v a2 s.c o m*/ df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.JAPAN); System.out.println("Japan: " + df.format(date)); df = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.KOREA); System.out.println("Korea: " + df.format(date)); df = DateFormat.getDateInstance(DateFormat.LONG, Locale.UK); System.out.println("United Kingdom: " + df.format(date)); df = DateFormat.getDateInstance(DateFormat.FULL, Locale.US); System.out.println("United States: " + df.format(date)); }
From source file:Main.java
/** Typical main method ("main program") declaration */ public static void main(String[] av) { Locale l1 = new Locale("en", "US"), l2 = new Locale("es", "ES"); // Create a Date object for May 5, 1986 Calendar c = Calendar.getInstance(); c.set(1986, 04, 05); // May 5, 1986 Date d1 = c.getTime();/*w ww .java2 s . c om*/ // Create a Date object for today. Date d2 = new Date(); // today DateFormat df_us = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, l1), df_sp = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, l2); System.out.println("Date d1 for US is " + df_us.format(d1)); System.out.println("Date d1 for Spain is " + df_sp.format(d1)); System.out.println("Date d2 is " + df_us.format(d2)); }
From source file:MainClass.java
public static void main(String[] args) { Date today = new Date(); Locale[] locales = { Locale.US, Locale.UK, Locale.GERMANY, Locale.FRANCE }; int[] styles = { DateFormat.FULL, DateFormat.LONG, DateFormat.MEDIUM, DateFormat.SHORT }; DateFormat fmt;// w w w . j av a 2s . c o m String[] styleText = { "FULL", "LONG", "MEDIUM", "SHORT" }; // Output the date for each local in four styles for (int i = 0; i < locales.length; i++) { System.out.println("\nThe Date for " + locales[i].getDisplayCountry() + ":"); for (int j = 0; j < styles.length; j++) { fmt = DateFormat.getDateInstance(styles[j], locales[i]); System.out.println("\tIn " + styleText[j] + " is " + fmt.format(today)); } } }
From source file:org.northrop.leanne.publisher.Main.java
public static void main(String[] args) { CommandLineParser parser = new GnuParser(); try {// w ww . j av a 2s.c om // parse the command line arguments CommandLine line = parser.parse(options, args); if (args.length == 0 || line.hasOption("help")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("pub", options); } else if (line.hasOption("version")) { URLClassLoader cl = (URLClassLoader) Main.class.getClassLoader(); String title = ""; String version = ""; String date = ""; try { URL url = cl.findResource("META-INF/MANIFEST.MF"); Manifest manifest = new Manifest(url.openStream()); Attributes attr = manifest.getMainAttributes(); title = attr.getValue("Implementation-Title"); version = attr.getValue("Implementation-Version"); date = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.MEDIUM) .format(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(attr.getValue("Built-Date"))); } catch (Exception e) { e.printStackTrace(); } System.out.println("------------------------------------------------------------"); System.out.println("Publisher Pipeline " + version); System.out.println("------------------------------------------------------------"); System.out.println(""); System.out.println(title + " build time " + date); System.out.println("Java: " + System.getProperty("java.version")); System.out.println("JVM: " + System.getProperty("java.vendor")); System.out.println("OS: " + System.getProperty("os.name") + " " + System.getProperty("os.version") + " " + System.getProperty("os.arch")); } else { Option[] options = line.getOptions(); Binding binding = new Binding(); binding.setVariable("home", System.getProperty("pub.home")); binding.setVariable("inputDir", System.getProperty("pub.home") + "/input"); binding.setVariable("outputDir", System.getProperty("pub.home") + "/output"); binding.setVariable("appName", System.getProperty("program.name")); binding.setVariable("isdebug", false); for (int i = 0; i < options.length; i++) { Option opt = options[i]; binding.setVariable("is" + opt.getOpt(), true); } String[] roots = new String[] { System.getProperty("pub.home") + "/resources/scripts", System.getProperty("pub.home") + "/resources/scripts/formats" }; ClassLoader parent = Main.class.getClassLoader(); GroovyScriptEngine gse = new GroovyScriptEngine(roots, parent); if (!line.hasOption("rerun")) { gse.run("prep.groovy", binding); } for (String name : getFormats()) { if (line.hasOption(name.toLowerCase())) { String file = ("" + name.charAt(0)).toLowerCase() + name.substring(1) + ".groovy"; gse.run(file, binding); } } } } catch (ParseException exp) { System.err.println("Command line parsing failed. Reason: " + exp.getMessage()); } catch (ResourceException resourceError) { System.err.println("Groovy script failed. Reason: " + resourceError.getMessage()); } catch (IOException ioError) { System.err.println("Groovy script failed. Reason: " + ioError.getMessage()); } catch (ScriptException error) { System.err.println("Groovy script failed. Reason: " + error.getMessage()); error.printStackTrace(); } }
From source file:org.easyrec.utils.Benchmark.java
public static void main(String[] args) { Connection con = null;// w ww. java 2 s. co m try { Class.forName("com.mysql.jdbc.jdbc2.optional.MysqlDataSource"); con = DriverManager.getConnection("jdbc:mysql://" + DB_HOST + "/" + DB_NAME, DB_USER, DB_PASSWORD); System.out.println("begin:" + DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT).format(new Date())); Statement st = con.createStatement(); initItemAndUserIds(); st.executeUpdate("DELETE FROM action;"); st.executeUpdate("DELETE FROM item;"); st.executeUpdate("DELETE FROM itemassoc;"); st.executeUpdate("DELETE FROM idmapping;"); System.out.println("db reset."); createItems(st); createIdMapping(st); createActions(st, NUMBER_OF_ACTIONS); startPlugins(); System.out.println("end:" + DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT).format(new Date())); } catch (Exception e) { e.printStackTrace(); } finally { if (con != null) { try { con.close(); } catch (SQLException ex) { logger.warn("An error occured", ex); } } } }
From source file:Main.java
public static String mediumFormat(Date date) { DateFormat dateFormat1 = DateFormat.getDateInstance(DateFormat.MEDIUM); return dateFormat1.format(date); }