LoginSignup
1
0

More than 5 years have passed since last update.

1月、2月…をJan. Feb. ...に変換する

Last updated at Posted at 2012-12-26

可読性のよいやり方↓

        public static string GetMonthStringEn(int month)
        {
            var date = new DateTime(2000, month, 1);
            System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo("en-US");

            return date.ToString("MMM", ci) + ".";
        }

別解↓

        public static string GetMonthStringEn(int month)
        {
            var invariantCulture = new CultureInfo(string.Empty, false);
            var monthString = DateTimeFormatInfo.GetInstance(invariantCulture).AbbreviatedMonthNames[month - 1];

            return monthString + ".";
        }

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0