Monday, 27 August 2012

Having a Date Time in a String in Java


  The following code snippet can be helpful in having a Date Time as a String in Java.

            Date dNow = new Date( );
            SimpleDateFormat ft = new SimpleDateFormat("dd:MM:yy HH:mm:ss");
            String date = ft.format(dNow.getTime());

  In the SimpleDateFormate constructor different date formats can be supplied as input.

No comments:

Post a Comment