Sample Programs

Sample java program to convert Date to String

 package org.jusfortechies.example; 

 import java.text.SimpleDateFormat;
 import java.util.Date;
 
 public class DateToString {

   private static final SimpleDateFormat simpleDateFormat = new SimpleDateFormat();
	
   private static final String DATE_FORMAT = "MM/dd/yyyy";
	
   public static void main(String[] args) {
      
      simpleDateFormat.applyPattern(DATE_FORMAT);
      String strDate = simpleDateFormat.format(new Date());
			
      System.out.println("Today's date = " + strDate);
      
   }

 }




blog comments powered by Disqus