how to convert long date value to mm/dd/yyyy format

andro-girl picture andro-girl · Aug 1, 2012 · Viewed 147.4k times · Source

Possible Duplicate:
converting long string to date

I need to convert long date value to mm/dd/yyyy format.my long value is

strDate1="1346524199000"

please help me

Answer

Suresh picture Suresh · Aug 1, 2012

Refer Below code which give the date in String form.

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



public class Test{

    public static void main(String[] args) {
        long val = 1346524199000l;
        Date date=new Date(val);
        SimpleDateFormat df2 = new SimpleDateFormat("dd/MM/yy");
        String dateText = df2.format(date);
        System.out.println(dateText);
    }
}