日期格式化 Mobile Flex 项目

发布于 2024-12-12 10:53:03 字数 1646 浏览 2 评论 0原文

我有一个可以获取 rss feed 的移动应用程序。 rss feed 上的日期显示周五,2011 年 10 月 28 日 17:30:00 GMT,我希望将其呈现为 cst 时间标准 dd/mm/yyyy 和时间中的短日期。我的应用程序的代码如下。任何帮助都会很棒 这是第一次使用 Adob​​e Flash Builder。

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark"
        xmlns:ns1="*"
        backgroundColor="#74171E" title="Mediacom 2 / Paulbunyan 32"
        viewActivate="refresh()">

    <fx:Script>
        <![CDATA[
            protected function getData():void
            {
                getDataResult.token = iCTVChannel232.getData();
            }
            public function refresh(): void {
                getData();
            } 
        ]]>


    </fx:Script>

    <fx:Declarations>
        <s:CallResponder id="getDataResult"/>
        <ns1:ICTVChannel232 id="iCTVChannel232"/>
    </fx:Declarations>
    <s:DataGrid id="dataGrid" left="10" right="10" top="10" bottom="10">
        <s:columns>
            <s:ArrayList>
                <s:GridColumn dataField="pubDate" width="65" headerText="Date"></s:GridColumn>
                <s:GridColumn dataField="title" headerText="Title"></s:GridColumn>
            </s:ArrayList>
        </s:columns>
        <s:AsyncListView list="{getDataResult.lastResult}"/>

    </s:DataGrid>
    <s:actionContent>
        <s:Button icon="@Embed('/assets/refreshico.png')"
                  click="Object(navigator.activeView).refresh()"/>
    </s:actionContent>

</s:View>

I have a mobile app that gets a rss feed. The date on the rss feed displays Fri, 28 Oct 2011 17:30:00 GMT and I would like that to render as a short date in cst time standard dd/mm/yyyy and time. The code for my app is below. any help would be great This is the first time working with Adobe Flash Builder.

<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:s="library://ns.adobe.com/flex/spark"
        xmlns:ns1="*"
        backgroundColor="#74171E" title="Mediacom 2 / Paulbunyan 32"
        viewActivate="refresh()">

    <fx:Script>
        <![CDATA[
            protected function getData():void
            {
                getDataResult.token = iCTVChannel232.getData();
            }
            public function refresh(): void {
                getData();
            } 
        ]]>


    </fx:Script>

    <fx:Declarations>
        <s:CallResponder id="getDataResult"/>
        <ns1:ICTVChannel232 id="iCTVChannel232"/>
    </fx:Declarations>
    <s:DataGrid id="dataGrid" left="10" right="10" top="10" bottom="10">
        <s:columns>
            <s:ArrayList>
                <s:GridColumn dataField="pubDate" width="65" headerText="Date"></s:GridColumn>
                <s:GridColumn dataField="title" headerText="Title"></s:GridColumn>
            </s:ArrayList>
        </s:columns>
        <s:AsyncListView list="{getDataResult.lastResult}"/>

    </s:DataGrid>
    <s:actionContent>
        <s:Button icon="@Embed('/assets/refreshico.png')"
                  click="Object(navigator.activeView).refresh()"/>
    </s:actionContent>

</s:View>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤千羽 2024-12-19 10:53:04

为了得到日期,我想我会做这样的事情(诚然,这可能不是最好的方法!):

//Making the Strings
private var getFeed:String = somehowGetRSSFeed();

private var theDateString:String = getMonth() +
                                "/" + 
                           getDay() + 
                                "/" +                                  
                           getYear();

//gets the month from the position of 9 and out to three places and make it a number
public function getMonth()
{
    switch(getFeed.substr(9, 3).toUpper())
    {
        case "JAN"
        {
            return "01";
        }
        .
        .
        .
        case "DEC"
        {
            return "12";
        }

    }
}

public function getDay()
{
    return getFeed.substr(5, 2);
}

public function getYear()
{
    return getFeed.substr(12, 4);
}

我认为这会起作用。你必须在我设置快捷方式的地方进行更改,但我认为你可以弄清楚。

另外,我不确定我实际上是否放置了正确的字符串位置,因此您可能需要更改它们。

to get the date I think I would do something like this (admittedly it might not be the best way!):

//Making the Strings
private var getFeed:String = somehowGetRSSFeed();

private var theDateString:String = getMonth() +
                                "/" + 
                           getDay() + 
                                "/" +                                  
                           getYear();

//gets the month from the position of 9 and out to three places and make it a number
public function getMonth()
{
    switch(getFeed.substr(9, 3).toUpper())
    {
        case "JAN"
        {
            return "01";
        }
        .
        .
        .
        case "DEC"
        {
            return "12";
        }

    }
}

public function getDay()
{
    return getFeed.substr(5, 2);
}

public function getYear()
{
    return getFeed.substr(12, 4);
}

I think this would work. You'd have to make changes where I made shortcuts, but I think you can figure it out.

Also, I'm not certain I actually put the correct position in for the strings, so you might have to change those.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文