Example:
Example of using SimpleDateFormat |
package java_time; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; /** * @web http://java-buddy.blogspot.com/ */ public class Java_Time { public static void main(String[] args) { Calendar now = Calendar.getInstance(); Date nowDate = now.getTime(); System.out.println(nowDate); SimpleDateFormat format; String formattedString; format = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss"); formattedString = format.format(nowDate); System.out.println(formattedString); format = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss(a)"); formattedString = format.format(nowDate); System.out.println(formattedString); } }
No comments:
Post a Comment