How to Get Short Date Format Pattern?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ellis Yu

    How to Get Short Date Format Pattern?

    Dear All

    I want to read the short date format pattern from the regional
    setting. I write a code as follow:

    'Diff. machine may has different country setting, so I use blank
    here
    Dim a as new CultureInfo("")
    Dim shortDatePatter n as String

    shortDatePatter n = a.DateTimeForma t.ShortDatePatt ern()

    But I found that the pattern is different to my regional setting one. Anyone
    know how to do? Thanks

    Best Rdgs
    Ellis


  • Ken Tucker [MVP]

    #2
    Re: How to Get Short Date Format Pattern?

    Hi,



    Ken
    ---------------
    "Ellis Yu" <ellis.yu@trans field.com> wrote in message
    news:%23GqITUlZ FHA.580@TK2MSFT NGP15.phx.gbl.. .
    Dear All

    I want to read the short date format pattern from the regional
    setting. I write a code as follow:

    'Diff. machine may has different country setting, so I use blank
    here
    Dim a as new CultureInfo("")
    Dim shortDatePatter n as String

    shortDatePatter n = a.DateTimeForma t.ShortDatePatt ern()

    But I found that the pattern is different to my regional setting one. Anyone
    know how to do? Thanks

    Best Rdgs
    Ellis



    Comment

    • Cor Ligthert

      #3
      Re: How to Get Short Date Format Pattern?

      Ellis,
      [color=blue]
      > 'Diff. machine may has different country setting, so I use blank
      > here[/color]
      [color=blue]
      > But I found that the pattern is different to my regional setting one.
      > Anyone
      > know how to do? Thanks[/color]

      You make me curious, how do you do that?

      Even if I would use a device to find the location by satalite, than I did
      not know the culture of the user.

      Cor


      Comment

      • Ellis Yu

        #4
        Re: How to Get Short Date Format Pattern?

        Thanks Ken, maybe I didn't explain clear enough of my problem. I want to get
        the short time format pattern from regional setting. Since the pattern maybe
        changed by the user, it's different to the default pattern. Just like the
        sample you given to me, if the culture is "en-US", then the short format
        will be "M/d/yyyy" even the user had used his customized format instead. If
        in that case, how can I do?


        "Ken Tucker [MVP]" <vb2ae@bellsout h.net> wrote in message
        news:uyJoJkmZFH A.1040@TK2MSFTN GP10.phx.gbl...[color=blue]
        > Hi,
        >
        >[/color]

        frlrfsystemglob alizationdateti meformatinfocla ssshortdatepatt erntopic.asp[color=blue]
        >
        > Ken
        > ---------------
        > "Ellis Yu" <ellis.yu@trans field.com> wrote in message
        > news:%23GqITUlZ FHA.580@TK2MSFT NGP15.phx.gbl.. .
        > Dear All
        >
        > I want to read the short date format pattern from the regional
        > setting. I write a code as follow:
        >
        > 'Diff. machine may has different country setting, so I use blank
        > here
        > Dim a as new CultureInfo("")
        > Dim shortDatePatter n as String
        >
        > shortDatePatter n = a.DateTimeForma t.ShortDatePatt ern()
        >
        > But I found that the pattern is different to my regional setting one.[/color]
        Anyone[color=blue]
        > know how to do? Thanks
        >
        > Best Rdgs
        > Ellis
        >
        >
        >[/color]


        Comment

        • Herfried K. Wagner [MVP]

          #5
          Re: How to Get Short Date Format Pattern?

          "Ellis Yu" <ellis.yu@trans field.com> schrieb:[color=blue]
          > Dim a as new CultureInfo("")
          > Dim shortDatePatter n as String
          >
          > shortDatePatter n = a.DateTimeForma t.ShortDatePatt ern()
          >
          > But I found that the pattern is different to my regional setting one.
          > Anyone
          > know how to do? Thanks[/color]

          Try this:

          \\\
          Imports System.Globaliz ation
          ..
          ..
          ..
          MsgBox(CultureI nfo.CurrentCult ure.DateTimeFor mat.ShortDatePa ttern)
          ///

          --
          M S Herfried K. Wagner
          M V P <URL:http://dotnet.mvps.org/>
          V B <URL:http://classicvb.org/petition/>

          Comment

          • Ken Tucker [MVP]

            #6
            Re: How to Get Short Date Format Pattern?

            Hi,

            Dim myDTFI As DateTimeFormatI nfo =
            Globalization.C ultureInfo.Curr entCulture.Date TimeFormat



            Ken

            ---------------------------

            "Ellis Yu" <ellis.yu@trans field.com> wrote in message
            news:%23DVNPPnZ FHA.2788@TK2MSF TNGP12.phx.gbl. ..
            Thanks Ken, maybe I didn't explain clear enough of my problem. I want to get
            the short time format pattern from regional setting. Since the pattern maybe
            changed by the user, it's different to the default pattern. Just like the
            sample you given to me, if the culture is "en-US", then the short format
            will be "M/d/yyyy" even the user had used his customized format instead. If
            in that case, how can I do?


            "Ken Tucker [MVP]" <vb2ae@bellsout h.net> wrote in message
            news:uyJoJkmZFH A.1040@TK2MSFTN GP10.phx.gbl...[color=blue]
            > Hi,
            >
            >[/color]

            frlrfsystemglob alizationdateti meformatinfocla ssshortdatepatt erntopic.asp[color=blue]
            >
            > Ken
            > ---------------
            > "Ellis Yu" <ellis.yu@trans field.com> wrote in message
            > news:%23GqITUlZ FHA.580@TK2MSFT NGP15.phx.gbl.. .
            > Dear All
            >
            > I want to read the short date format pattern from the regional
            > setting. I write a code as follow:
            >
            > 'Diff. machine may has different country setting, so I use blank
            > here
            > Dim a as new CultureInfo("")
            > Dim shortDatePatter n as String
            >
            > shortDatePatter n = a.DateTimeForma t.ShortDatePatt ern()
            >
            > But I found that the pattern is different to my regional setting one.[/color]
            Anyone[color=blue]
            > know how to do? Thanks
            >
            > Best Rdgs
            > Ellis
            >
            >
            >[/color]



            Comment

            Working...