Skip to content

Instantly share code, notes, and snippets.

@odan
Created March 18, 2024 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save odan/34b929f87430ed5d8346d9d40e9bd790 to your computer and use it in GitHub Desktop.
Save odan/34b929f87430ed5d8346d9d40e9bd790 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Globalization;
// CultureInfo culture = new CultureInfo("en-US");
// Full-date notation as defined by RFC 3339, section 5.6, for example, 2024-03-28
string date1 = string.Format("{0:yyyy}-{0:MM}-{0:dd}", DateTime.Now);
Console.WriteLine(date1);
// RFC 3339, section 5.6, for example, 2024-03-28T17:32:28Z
string date2 = string.Format("{0:yyyy}-{0:MM}-{0:dd}T{0:hh}:{0:mm}:{0:ss}Z", DateTime.Now);
Console.WriteLine(date2);
// Curreny format CHF
NumberFormatInfo info = (NumberFormatInfo)CultureInfo.InvariantCulture.NumberFormat.Clone();
info.NumberGroupSeparator = "'";
info.NumberDecimalSeparator = ".";
// 2'147'483'647.00
Console.WriteLine(int.MaxValue.ToString("n", info));
// 123'456'789.12
Console.WriteLine(123456789.12.ToString("n", info));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment