English 中文(简体)
“第6号,2012年11:12号”格式的更改日期
原标题:Convert Date time in "Mon APR 6, 2012 11:12 am" format
  • 时间:2012-04-24 06:49:57
  •  标签:
  • android

我想改变日期。

Mon APR 6, 2012  11:12 am

表格

i 使用

SimpleDateFormat formatter = new SimpleDateFormat("EE MMM d, yyyy hh:mm a");
String date = formatter.format(d);

该守则将采用日期格式,但该守则将返回。

Mon Apr 6, 2012  11:12 am

i Caps需要月,其他所有时间相同。

如果有解决办法,请参见我。

成就

最佳回答

Take a look at DateFormatSymbols http://docs.oracle.com/javase/1.4.2/docs/api/java/text/DateFormatSymbols.html

样本:

DateFormatSymbols symbols = new DateFormatSymbols();
symbols.setShortMonths(new String[]{"JAN","FEB"....});
SimpleDateFormat format = new SimpleDateFormat("EE MMM d, yyyy hh:mm a", symbols);
问题回答

您可在Mon Apr 6, 2012 11:12 am上查阅,并在使用聊天机(聊天机)功能时每月作为记号。 之后,在修缮班时采用“上调”方法,使其升学。

提要

import java.text.SimpleDateFormat;
import java.util.Date;

class Solution
{
        public static void main (String[] args)
        {
                Date d = new java.util.Date();
                SimpleDateFormat formatter = new SimpleDateFormat("EE MMM d, yyyy hh:mm a");
                String date = formatter.format(d);
                String month = date.substring(4, 7);
                date = date.replaceFirst(month, month.toUpperCase());
                System.out.println(date);

        }
}

但是,如果你的日期格式发生变化,那就没有工作了。 你们需要理解这一点。

D. 守则

Date d = new Date();
        SimpleDateFormat formatter = new SimpleDateFormat("EE MMM d, yyyy hh:mm a");
        String date = formatter.format(d);
        Log.v("Test","Date==="+d);
        String[] temp;
        String month ;
        String final_string_date = "" ;
        temp = date.split(" ");
        for(int i =0; i < temp.length ; i++)
        {
            if(i==1)
                month=temp[i].toUpperCase();
            else
                month=temp[i];
            final_string_date = final_string_date+" "+  month;
        }
        Log.v("Test","final_string_date==="+final_string_date.trim());
public static String DateFormat(String repdate,SimpleDateFormat formater )
{
    long d = Date.parse(repdate);       
    String[] arr= formater.format(d).split(" ");
    arr[1] = arr[1].toUpperCase();
    String date = "";
    for(int i=0;i<arr.length;i++)
    {
        date = date + arr[i] +" ";
    }

    return date;
}

采用你目前的编号和日期格式(“EE MMM d, yyyy hh:mm a”)。 你将找到解决办法。





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签