Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

272
Visualizações
Custom format Korean date with forward-slash not working

If you run the following code: https://dotnetfiddle.net/kBqe9x

using System;
                    
public class Program
{
    public static void Main()
    {
        var date = DateTime.Now;
        Console.WriteLine(date.ToString("yyyy/MM/dd", System.Globalization.CultureInfo.GetCultureInfo("ko-KR")));
    }
}

The result will be 2022-01-18.

Why is .net replacing the forward-slash with a dash?

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

The forward slash is a special character, in DateTime you have to write that like '/'

using System;
                    
public class Program
{
    public static void Main()
    {
        var date = DateTime.Now;
        Console.WriteLine(date.ToString("yyyy'/'MM'/'dd", System.Globalization.CultureInfo.GetCultureInfo("ko-KR")));
    }
}
over 4 years ago · Santiago Trujillo Relatório

0

That's because ko-KR culture info has such a date pattern for a short date. If you take a look at the ShortDatePattern property of the CultureInfo you've created here, you'll see the following.

var cultureInfo = System.Globalization.CultureInfo.GetCultureInfo("ko-KR");
Console.WriteLine(cultureInfo.DateTimeFormat.ShortDatePattern);

This prints out: yyyy-MM-dd

Fiddle: https://dotnetfiddle.net/CRxKtQ

If you want to keep the pattern you specified in ToString method, simply remove the culture info.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda