2012-01-06 12 views
1

電話で一部の地域形式を選択すると、24時間形式で時間を表示するかどうかを選択できる日付+時刻のオプションが表示されます。12/24時間表示設定を検出する

この設定を読む方法はありますか?私はこの設定に基づいて私のアプリの時間を表示したいですか?

ありがとうございます。

+0

ToString()は自動的に現在のシステム設定を使用していますか? – GSerg

+0

私はそれを使用している方法ではありません。私はウェブからデータを読んでいます(フォーマット14:32)ので、電話の設定に応じて14:32または2:32 PMにフォーマットする必要があります。 – John

+0

DateTime.ParseExact(テキスト、 "HH:mm"、CultureInfo.CurrentCulture).ToString()は正しい形式で正しい時刻を返しますが、日付も取得します。 – John

答えて

0

このリンクを使用して、C#からすべての種類をダウンロードすることもできます。 VBのWindowsスマートフォンコード Globalization Code and Downloads

このリンクは、MSDNのdownloadesはまた、Windowsスマートフォン

// set this thread's current culture to the culture associated with the selected locale 
      CultureInfo newCulture = new CultureInfo(cul); 
      Thread.CurrentThread.CurrentCulture = newCulture; 

      CultureInfo cc, cuic; 
      cc = Thread.CurrentThread.CurrentCulture; 
      cuic = Thread.CurrentThread.CurrentUICulture; 

      // display the culture name in the language of the selected locale 
      regionalFrmt.Text = cc.NativeName; 

      // display the culture name in the localized language 
      displayLang.Text = cuic.DisplayName; 

      // display the date formats (long and short form) for the current culuture 
      DateTime curDate = DateTime.Now; 
      longDate.Text = cc.DateTimeFormat.LongDatePattern.ToString() + " " + curDate.ToString("D"); 
      shortDate.Text = cc.DateTimeFormat.ShortDatePattern.ToString() + " " + curDate.ToString("d"); 

      // display the time format (long form) for the current culture 
      longTime.Text = cc.DateTimeFormat.LongTimePattern + " " + curDate.ToString("T"); 
+1

24時間表示または12時間表示のフラグが見つかりません。 – John

0

DateTimeFormatInfo documentationによるとをコードしている場合は他の事のお手伝いをすべきである、「DateTimeFormatInfo.ShortTimePattern値がありません時刻が24時間に設定されているときに変更されます。プロパティ値は "h:mm"になりますが、 "h:mm tt"のままです(ttはAMまたはPMです)。

これはバグのようです。うまくいけば、はWindowsPhone8で修正されます。

とにかく、あなたの質問に答えるために...あなたはこれを使用することができます:

string pattern = CultureInfo.CurrentCulture.DateTimeFormat.LongTimePattern.Replace(":ss", ""); 

これはSilverlight Toolkitから取られました。

関連する問題