当前位置: 首页>>代码示例>>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;未经允许,请勿转载。