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
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
 
    
     
    
    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);
    }
}
 
    
    Refer below code for formatting date
long strDate1 = 1346524199000;
Date date = new Date(strDate1);
try {
        SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z");
        SimpleDateFormat df2 = new SimpleDateFormat("dd/MM/yy");
        date = df2.format(format.parse("yourdate");
    } catch (java.text.ParseException e) {
        e.printStackTrace();
    }
 
    
     
    
    Try this example
 String[] formats = new String[] {
   "yyyy-MM-dd",
   "yyyy-MM-dd HH:mm",
   "yyyy-MM-dd HH:mmZ",
   "yyyy-MM-dd HH:mm:ss.SSSZ",
   "yyyy-MM-dd'T'HH:mm:ss.SSSZ",
 };
 for (String format : formats) {
   SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.US);
   System.err.format("%30s %s\n", format, sdf.format(new Date(0)));
   sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
   System.err.format("%30s %s\n", format, sdf.format(new Date(0)));
 }
and read this http://developer.android.com/reference/java/text/SimpleDateFormat.html
 
    
     
    
    Try something like this:
public class test 
{  
    public static void main(String a[])
    {  
        long tmp = 1346524199000;  
        Date d = new Date(tmp);  
        System.out.println(d);  
    }  
} 
