List of usage examples for java.text SimpleDateFormat SimpleDateFormat
public SimpleDateFormat(String pattern)
SimpleDateFormat
using the given pattern and the default date format symbols for the default java.util.Locale.Category#FORMAT FORMAT locale. From source file:Main.java
public static void main(String[] args) throws Exception { String someDate = "22/03/2015"; SimpleDateFormat strToDate = new SimpleDateFormat("dd/MM/yyyy"); Date currentDate = strToDate.parse(someDate); System.out.println("Date is : " + currentDate); String dateFormat = "yyyy-MM-dd HH:mm:ss.SSS"; SimpleDateFormat dateToStr = new SimpleDateFormat(dateFormat); String formattedDate = dateToStr.format(currentDate); System.out.println("Formated Date is : " + formattedDate); }
From source file:Main.java
public static void main(String[] args) throws Exception { String source = new String("03/20/2015"); SimpleDateFormat sdfinput = new SimpleDateFormat("MM/dd/yyyy"); SimpleDateFormat sdfoutput = new SimpleDateFormat("yyyy-MM-dd"); Date inputdate = sdfinput.parse(source); String outputDate = sdfoutput.format(inputdate); System.out.println(outputDate); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Format formatter = new SimpleDateFormat("MMM"); CharacterIterator s = formatter.formatToCharacterIterator(new Date()); System.out.println(s.last()); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Date date = new Date(); SimpleDateFormat simpDate;/*w w w .jav a 2s. c o m*/ simpDate = new SimpleDateFormat("EEEE MMMMM dd yyyy kk:mm:ss"); System.out.println(simpDate.format(date)); }
From source file:MainClass.java
public static void main(String[] args) throws ParseException { try {/*from w w w . j a v a2 s . c om*/ SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd"); String date = "2003/01/10"; java.util.Date utilDate = formatter.parse(date); java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime()); System.out.println("date:" + date); System.out.println("sqlDate:" + sqlDate); } catch (ParseException e) { System.out.println(e.toString()); e.printStackTrace(); } }
From source file:Main.java
public static void main(String[] argv) throws Exception { Date date = new Date(); SimpleDateFormat simpDate;/*from w w w. j a v a 2s . com*/ simpDate = new SimpleDateFormat("dd MMM yyyy hh:mm:ss a"); System.out.println(simpDate.format(date)); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Date date = new Date(); SimpleDateFormat simpDate;// w w w . j a v a 2 s. c o m simpDate = new SimpleDateFormat("hh:mm:ss a"); System.out.println(simpDate.format(date)); }
From source file:Main.java
public static void main(String[] args) throws Exception { String time = "15:30:18"; DateFormat sdf = new SimpleDateFormat("hh:mm:ss"); Date date = sdf.parse(time);/*from ww w . j av a2s.c o m*/ System.out.println("Date and Time: " + date); }
From source file:Main.java
public static void main(String[] argv) throws Exception { Date date = new Date(); SimpleDateFormat simpDate;//from w w w . j a v a2s . c o m simpDate = new SimpleDateFormat("kk:mm:ss"); System.out.println(simpDate.format(date)); }
From source file:Main.java
public static void main(String[] args) { int year = 2015; int month = 4; SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy"); GregorianCalendar calendar = new GregorianCalendar(year, month, 1); while (calendar.get(GregorianCalendar.MONTH) == month) { String dateString = format.format(calendar.getTime()); System.out.println(dateString); calendar.add(GregorianCalendar.DATE, 1); }//from ww w . ja v a 2s . co m }