2012-01-12 17 views
13

क्या 04 जनवरी, 2012 में "0" को निकालना संभव है?महीने के दिन में अग्रणी "0" निकालें SimpleDateFormat

मैं वर्तमान में निम्नलिखित जावा का उपयोग कर रहा तरह

Monday, January 04, 2012 

दिनांक स्वरूप पाने के लिए मैं इसे पसंद

Monday, January 4, 2012 

    Date anotherCurDate = new Date(); 

    SimpleDateFormat formatter = new SimpleDateFormat("EEEE', 'MMMM dd', ' yyyy"); 
    final String formattedDateString = formatter.format(anotherCurDate); 

final TextView currentRoomDate = (TextView) this.findViewById(R.id.CurrentDate); 

उत्तर

33
SimpleDateFormat formatter = new SimpleDateFormat("EEEE', 'MMMM d', ' yyyy"); 

देखने के लिए के लिए यह करना चाहिए चाहते हैं (एक 'प' दो के बजाय)?

http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html

+0

बेशक यह है कि आसान होगा। मुझे लगा कि इसे ठीक करने के लिए कुछ पोस्ट प्रक्रिया होने जा रही थी। धन्यवाद मैं अब परीक्षण करूंगा। – Denoteone

+0

हे, इसे किसी कारण के लिए 'सरल' दिनांक फ़ॉर्मेटर कहा जाता है;) यदि आपने इसे नहीं देखा है, तो मैंने इसके लिए प्रलेखन का एक लिंक जोड़ा है। – Jave

+0

जो +1 काम करता है और मैं 5 मिनट में प्रश्न की जांच करूंगा – Denoteone

0

तुम बस ऐसा करने से एक नंबर के सामने "0" के बिना एक स्ट्रिंग प्राप्त कर सकते हैं:

Calendar today = Calendar.getInstance(); 
// If you want the day/month in String format 
String month = today.get(Calendar.MONTH)+""; 

// If you want the day/month in Integer format 
int monthInt = (int) Integer.parseInt(month); 
संबंधित मुद्दे