List of usage examples for java.text DateFormat FULL
int FULL
To view the source code for java.text DateFormat FULL.
Click Source Link
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 ww w .j av a2s. c o m*/ try { Date date = shortDf.parse("12/12/2006"); } catch (ParseException e) { } }
From source file:TimeFormatDemo.java
public static void main(String args[]) { Date date = new Date(); DateFormat df;//from ww w . j a v a2s . c o m df = DateFormat.getTimeInstance(DateFormat.SHORT, Locale.JAPAN); System.out.println("Japan: " + df.format(date)); df = DateFormat.getTimeInstance(DateFormat.LONG, Locale.UK); System.out.println("United Kingdom: " + df.format(date)); df = DateFormat.getTimeInstance(DateFormat.FULL, Locale.CANADA); System.out.println("Canada: " + df.format(date)); }
From source file:Main.java
public static void main(String[] args) { Date now = new Date(); DateFormat defaultFormat = DateFormat.getDateTimeInstance(); String defaultString = defaultFormat.format(now); System.out.println("Default : " + defaultString); DateFormat antarcticaFormat = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, new Locale("en", "AQ")); String antarcticaString = antarcticaFormat.format(now); System.out.println("Antarctica: " + antarcticaString); }
From source file:MainClass.java
public static void main(String args[]) { Date date = new Date(); DateFormat df;/* ww w . ja v a2 s. c om*/ 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:AntarcticaLocaleDemo.java
public static void main(String [] args) { Date now = new Date(); DateFormat defaultFormat = DateFormat.getDateTimeInstance(); String defaultString = defaultFormat.format (now); System.out.println ("Default : " + defaultString); DateFormat antarcticaFormat = DateFormat.getDateTimeInstance ( DateFormat.FULL, DateFormat.FULL, new Locale ("en", "AQ")); String antarcticaString = antarcticaFormat.format (now); System.out.println ("Antarctica: " + antarcticaString); }
From source file:JFormattedTextFieldDateInputSampleDateFormatFULLLocaleUS.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. ja v a 2s . c om JFormattedTextField input; JPanel panel; BoxLayout layout = new BoxLayout(frame.getContentPane(), BoxLayout.Y_AXIS); frame.setLayout(layout); Format fullUSDate = DateFormat.getDateInstance(DateFormat.FULL, Locale.US); label = new JLabel("Full US date:"); input = new JFormattedTextField(fullUSDate); input.setValue(new Date()); input.setColumns(20); panel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); panel.add(label); panel.add(input); frame.add(panel); frame.add(new JTextField()); frame.pack(); frame.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 ww w.jav a 2 s . c om*/ 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:JapaneseCalendar.java
public static void main(String[] args) { Locale japanese = new Locale("ja", "JP", "JP"); Calendar cal = Calendar.getInstance(japanese); DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, japanese); String str = df.format(cal.getTime()); JOptionPane.showMessageDialog(null, str); }
From source file:Main.java
public static void main(String[] args) throws Exception { String host = "host"; int port = 25; String from = "from@from.net"; String toAddr = "to@to.net"; Socket servSocket = new Socket(host, port); DataOutputStream os = new DataOutputStream(servSocket.getOutputStream()); DataInputStream is = new DataInputStream(servSocket.getInputStream()); if (servSocket != null && os != null && is != null) { os.writeBytes("HELO\r\n"); os.writeBytes("MAIL From:" + from + " \r\n"); os.writeBytes("RCPT To:" + toAddr + "\r\n"); os.writeBytes("DATA\r\n"); os.writeBytes("X-Mailer: Java\r\n"); os.writeBytes(/*from ww w.j a v a2s. c om*/ "DATE: " + DateFormat.getDateInstance(DateFormat.FULL, Locale.US).format(new Date()) + "\r\n"); os.writeBytes("From:" + from + "\r\n"); os.writeBytes("To:" + toAddr + "\r\n"); } os.writeBytes("Subject:\r\n"); os.writeBytes("body\r\n"); os.writeBytes("\r\n.\r\n"); os.writeBytes("QUIT\r\n"); String responseline; while ((responseline = is.readUTF()) != null) { if (responseline.indexOf("Ok") != -1) break; } }
From source file:DateFormatBest.java
public static void main(String[] args) { Date today = new Date(); DateFormat df = DateFormat.getInstance(); System.out.println(df.format(today)); DateFormat df_fr = DateFormat.getDateInstance(DateFormat.FULL, Locale.FRENCH); System.out.println(df_fr.format(today)); }