【问题标题】:Android: Date Format in Month date yearAndroid:月日年的日期格式
【发布时间】:2012-05-24 04:56:49
【问题描述】:

我在应用程序中的日期显示为 07/10/2011(dd/MM/yyyy)...我希望日期格式为 2011 年 10 月 7 日,采用 android 编码。请帮助作为 Android 新手

【问题讨论】:

    标签: android date-format simpledateformat android-date


    【解决方案1】:
        DateFormat f = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.ENGLISH);
        String dateString = f.format(new Date());
    

    【讨论】:

      【解决方案2】:
      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

      【讨论】:

        【解决方案3】:

        SimpleDateFormat dateFormat= new SimpleDateFormat("MMM dd, yyyy", Locale.US); dateFormat.format(new Date(0)));

        http://developer.android.com/reference/android/text/format/DateFormat.html http://developer.android.com/reference/java/text/SimpleDateFormat.html

        【讨论】:

        • 嗯,我查看了链接..它帮助了我......非常感谢。
        【解决方案4】:
        String mydate = java.text.DateFormat.getDateTimeInstance().format(Calendar.getInstance().getTime());
        
            TextView _dateText=(TextView)_view.findViewById(R.id.dateTextView);
            _dateText.setText(""+mydate);
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2015-04-29
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2013-10-25
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多