Code to convert the given date to - form..(eg:11/11/2011 to 11-11-2011)..in Android

String datestr="11/11/2011";
        SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy");
        Date date1=null;
        try {
            date1 = df.parse(datestr);
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }///Converting the given String to Date dataType..
        String date=(String) android.text.format.DateFormat.format("MM-dd-yyyy", date1);
        System.out.println("----------updateDate----"+date);

Comments

Popular posts from this blog

Custom Dialog with no title and full screen in Android

code to display .pdf,.text,.DOC,.DOCX,.doc extension files exists in SDCard

Best working code to set Date limits on Date Picker Dialog,in Android