2012-05-24 38 views

回答

0
String mydate = java.text.DateFormat.getDateTimeInstance().format(Calendar.getInstance().getTime()); 

    TextView _dateText=(TextView)_view.findViewById(R.id.dateTextView); 
    _dateText.setText(""+mydate); 
3
DateFormat f = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.ENGLISH); 
    String dateString = f.format(new Date()); 
3
private void dateformation() { 
     SimpleDateFormat dateformate = new SimpleDateFormat("MMM dd, yyyy"); 
     Calendar currentDate = Calendar.getInstance(); 

     String currentDateStr = dateformate.format(currentDate.getTime()); 
     Log.i("Infoe ", " " + currentDateStr.toString()); 
     System.out.println("Current date is : " + currentDateStr); 
     // //=== OR 

     SimpleDateFormat sdf = new SimpleDateFormat("MMM dd, yyyy"); 

     sdf.applyPattern("MMM dd, yyyy"); 
     Date x = new Date(currentDate.get(Calendar.YEAR) - 1900, 
       currentDate.get(Calendar.MONTH), 
       currentDate.get(Calendar.DAY_OF_MONTH)); 
     Log.i("Infoe ", " " + sdf.format(x)); 
     System.out.println(sdf.format(x)); 

    } 

Date Format Types

+0

感謝您的編碼 – AnnaSmith