當前位置: 首頁>>代碼示例>>C#>>正文


C# DateTimeFormatInfo.GetJavaPattern方法代碼示例

本文整理匯總了C#中System.Globalization.DateTimeFormatInfo.GetJavaPattern方法的典型用法代碼示例。如果您正苦於以下問題:C# DateTimeFormatInfo.GetJavaPattern方法的具體用法?C# DateTimeFormatInfo.GetJavaPattern怎麽用?C# DateTimeFormatInfo.GetJavaPattern使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Globalization.DateTimeFormatInfo的用法示例。


在下文中一共展示了DateTimeFormatInfo.GetJavaPattern方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetStandardPattern

        public static string GetStandardPattern(char format, DateTimeFormatInfo dfi, bool forDateTimeOffset, out bool useutc, out bool use_invariant, out bool needsTranslation)
        {
            String pattern;

            useutc = false;
            use_invariant = false;
            needsTranslation = true;

            switch (format)
            {
                case 'd':
                    if(dfi.ShortDatePattern != null)
                        pattern = dfi.ShortDatePattern;
                    else
                    {
                        pattern = dfi.GetJavaPattern(DateFormat.SHORT, -1);
                        needsTranslation = false;
                    }
                    break;
                case 'D':
                    if (dfi.LongDatePattern != null)
                        pattern = dfi.LongDatePattern;
                    else
                    {
                        pattern = dfi.GetJavaPattern(DateFormat.FULL, -1);
                        needsTranslation = false;
                    }
                    break;
                case 'f':
                    if (dfi.LongDatePattern != null && dfi.ShortTimePattern != null)
                        pattern = dfi.LongDatePattern + " " + dfi.ShortTimePattern;
                    else
                    {
                        pattern = dfi.GetJavaPattern(DateFormat.FULL, DateFormat.SHORT);
                        needsTranslation = false;
                    }
                    break;
                case 'F':
                    if (dfi.FullDateTimePattern != null)
                        pattern = dfi.FullDateTimePattern;
                    else
                    {
                        pattern = dfi.GetJavaPattern(DateFormat.FULL, DateFormat.MEDIUM);
                        needsTranslation = false;
                    }
                    break;
                case 'g':
                    if (dfi.ShortDatePattern != null && dfi.ShortTimePattern != null)
                        pattern = dfi.ShortDatePattern + " " + dfi.ShortTimePattern;
                    else
                    {
                        pattern = dfi.GetJavaPattern(DateFormat.SHORT, DateFormat.SHORT);
                        needsTranslation = false;
                        
                    }
                    break;
                case 'G':
                    if (dfi.ShortDatePattern != null && dfi.LongTimePattern != null)
                        pattern = dfi.ShortDatePattern + " " + dfi.LongTimePattern;
                    else
                    {
                        pattern = dfi.GetJavaPattern(DateFormat.SHORT, DateFormat.MEDIUM);
                        needsTranslation = false;
                        
                    }
                    break;
                case 'm':
                case 'M':
                    pattern = dfi.MonthDayPattern;
                    break;
                case 'o':
                case 'O':
                    pattern = dfi.RoundtripPattern;
                    use_invariant = true;
                    break;
                case 'r':
                case 'R':
                    pattern = dfi.RFC1123Pattern;
                    if (forDateTimeOffset)
                        useutc = true;
                    use_invariant = true;
                    break;
                case 's':
                    pattern = dfi.SortableDateTimePattern;
                    use_invariant = true;
                    break;
                case 't':
                    if (dfi.ShortTimePattern != null)
                        pattern = dfi.ShortTimePattern;
                    else
                    {
                        pattern = dfi.GetJavaPattern(-1, DateFormat.SHORT);
                        needsTranslation = false;
                    }
                    break;
                case 'T':
                    if (dfi.LongTimePattern != null)
                        pattern = dfi.LongTimePattern;
                    else
                    {
//.........這裏部分代碼省略.........
開發者ID:sebastianhaba,項目名稱:api,代碼行數:101,代碼來源:DateTimeFormatting.cs


注:本文中的System.Globalization.DateTimeFormatInfo.GetJavaPattern方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。