🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: be.comp.programming
Article #1352

Re: [ASP.Net] String naar Datum

#1352
From: Pieter Philippaerts
Date: Tue, 29 Mar 2005 18:33
30 lines
2289 bytes
"aikie" <pierreiGEENSPAM@yucom.be> wrote in message
> Wat moet ik hier aan doen? Zodat de datums standaard in dag/maand/jaar 
> notatie komen?

Ik kan je probleem hier niet direct reproduceren, maar je kan twee dingen 
proberen. Je kan eens een Belgische DateTimeFormat meegeven, misschien dat 
hij dan de europese notatie als standaard gaat nemen. Een tweede optie is 
ParseExact gebruiken, maar dit enkel als je zeker bent van het gebruikte 
datum-formaat natuurlijk.

using System;
using System.Globalization;

// met Parse en DateTimeFormat
CultureInfo ci = new CultureInfo(0x0813, true);
DateTime dt = DateTime.Parse("21/03/2005", ci.DateTimeFormat);
Console.WriteLine(dt.ToString("D"));
dt = DateTime.Parse("05/03/2005", ci.DateTimeFormat);
Console.WriteLine(dt.ToString("D"));
// met ParseExact
string[] formats = new string[] {"dd/MM/yyyy", "dd/M/yyyy", "d/M/yyyy"};
dt = DateTime.ParseExact("21/03/2005", formats, ci.DateTimeFormat, 
DateTimeStyles.None);
Console.WriteLine(dt.ToString("D"));
dt = DateTime.ParseExact("5/3/2005", formats, ci.DateTimeFormat, 
DateTimeStyles.None);
Console.WriteLine(dt.ToString("D"));

Mvg,
Pieter Philippaerts
Technical Details
Message-ID: <1112121215.616470@seven.kulnet.kuleuven.ac.be>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!syros.belnet.be!ikaria.belnet.be!news.belnet.be!not-for-mail
References: <424958a2$0$30167$ba620e4c@news.skynet.be>

Show Full Headers
Complete Article Headers
X-Google-Thread: fcea4,dadb0a211d8946f2
X-Google-Attributes: gidfcea4,public
X-Google-Language: DUTCH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!syros.belnet.be!ikaria.belnet.be!news.belnet.be!not-for-mail
From: "Pieter Philippaerts" <Pieter.nospam@mentalis.org>
Newsgroups: be.comp.programming
Subject: Re: [ASP.Net] String naar Datum
Date: Tue, 29 Mar 2005 20:33:58 +0200
Organization: KULeuvenNet
Lines: 32
Message-ID: <1112121215.616470@seven.kulnet.kuleuven.ac.be>
References: <424958a2$0$30167$ba620e4c@news.skynet.be>
NNTP-Posting-Host: seven.kulnet.kuleuven.ac.be
X-Trace: ikaria.belnet.be 1112121215 10635 134.58.127.12 (29 Mar 2005 18:33:35 GMT)
X-Complaints-To: abuse@belnet.be
NNTP-Posting-Date: Tue, 29 Mar 2005 18:33:35 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
X-RFC2646: Format=Flowed; Response
Cache-Post-Path: seven.kulnet.kuleuven.ac.be!unknown@localhost
X-Cache: nntpcache 2.4.0b5 (see http://www.nntpcache.org/)