user defined date format

by rajesh 2009-12-30 16:27:10


Printing java date and time in user different format:

We have to use SimpleDateFormat to do this..


Example Code:

    import java.util.Date;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;

    public String getDateTime() {
        DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
        Date date = new Date();
        return dateFormat.format(date);
    }

Tagged in:

1395
like
0
dislike
0
mail
flag

You must LOGIN to add comments