Search code examples
javaandroiddatedata-conversion

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


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


Solution

  • 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);
        }
    }