List of usage examples for java.text DateFormat SHORT
int SHORT
To view the source code for java.text DateFormat SHORT.
Click Source Link
From source file:Main.java
public static void main(String[] argv) throws Exception { Locale locale = Locale.ITALIAN; Date date = new Date(); String s = DateFormat.getTimeInstance(DateFormat.SHORT, locale).format(date); System.out.println(s);/* w ww . j a va 2 s . com*/ }
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.SHORT, locale); String s = df.format(date);/*w w w. j av a 2 s. c o m*/ System.out.println(s); }
From source file:MainClass.java
public static void main(String args[]) { Date date = new Date(); DateFormat df;//ww w. ja v a 2 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
public static void main(String[] args) { Date date = new Date(); String strDate = DateFormat.getDateInstance(DateFormat.DEFAULT).format(date); System.out.println(strDate);/*from w ww .j a v a 2s .c o m*/ strDate = DateFormat.getDateInstance(DateFormat.FULL).format(date); System.out.println(strDate); strDate = DateFormat.getDateInstance(DateFormat.LONG).format(date); System.out.println(strDate); strDate = DateFormat.getDateInstance(DateFormat.SHORT).format(date); System.out.println(strDate); }
From source file:JFormattedTextFieldDateInputSampleDateFormatSHORT.java
public static void main(String args[]) { JFrame frame = new JFrame("Date/Time Input"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label;//from w w w. j ava2 s .co m JFormattedTextField input; JPanel panel; BoxLayout layout = new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS); frame.setLayout(layout); Format shortDate = DateFormat.getDateInstance(DateFormat.SHORT); label = new JLabel("Short date:"); input = new JFormattedTextField(shortDate); input.setValue(new Date()); input.setColumns(20); panel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); panel.add(label); panel.add(input); frame.add(panel); frame.pack(); frame.setVisible(true); }
From source file:EventObject.java
public static void main(String[] args) { JFrame f = new JFrame(); JButton ok = new JButton("Ok"); ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(event.getWhen()); Locale locale = Locale.getDefault(); String s = DateFormat.getTimeInstance(DateFormat.SHORT, locale).format(new Date()); if (event.getID() == ActionEvent.ACTION_PERFORMED) System.out.println(" Event Id: ACTION_PERFORMED"); System.out.println(" Time: " + s); String source = event.getSource().getClass().getName(); System.out.println(" Source: " + source); int mod = event.getModifiers(); if ((mod & ActionEvent.ALT_MASK) > 0) System.out.println("Alt "); if ((mod & ActionEvent.SHIFT_MASK) > 0) System.out.println("Shift "); if ((mod & ActionEvent.META_MASK) > 0) System.out.println("Meta "); if ((mod & ActionEvent.CTRL_MASK) > 0) System.out.println("Ctrl "); }//from ww w . j a v a 2 s. c om }); f.add(ok); f.setSize(420, 250); f.setLocationRelativeTo(null); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); }
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;/*from w w w. jav a2 s . co 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.easyrec.utils.Benchmark.java
public static void main(String[] args) { Connection con = null;/*from w w w.j a v a 2 s .c o 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 boolean isValidDateStr(String date) throws Exception { DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT); df.setLenient(false);/* w ww . j av a 2 s . c om*/ df.parse(date); return true; }
From source file:Main.java
private static DateFormat defaultTimeFormat() { return SimpleDateFormat.getTimeInstance(DateFormat.SHORT); }