2012-01-06 5 views
1

전화에서 일부 지역 형식을 선택하면 24 시간 형식으로 시간을 표시할지 여부를 선택할 수있는 날짜 + 시간 옵션이 제공됩니다.12/24 시간 표시 설정 감지

해당 설정을 읽을 수있는 방법이 있습니까? 이 설정을 기반으로 내 앱의 시간을 표시하고 싶습니다.

미리 감사드립니다.

+0

음,'ToString()'은 자동으로 현재의 시스템 설정을 사용하고 있지 않습니까? – GSerg

+0

내가 사용하는 방식이 아닙니다. 웹에서 데이터를 읽고 (형식 14:32) 14:32 또는 오후 2시 32 분으로 전화 설정에 따라 형식을 지정해야합니다. – John

+0

DateTime.ParseExact (텍스트, "HH : mm", CultureInfo.CurrentCulture) .ToString()은 올바른 형식으로 정확한 시간을 제공하지만 그 다음에는 날짜도 가져오고 시간 만 필요합니다. – John

답변

0

이 링크를 사용하면 모든 종류의 C#을 다운로드 할 수 있습니다. VB 윈도우 스마트 폰 코드 Globalization Code and Downloads

이 링크는 MSDN의 downloades는 또한 윈도우 스마트 폰

// 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에서 찍은.