473,799 Members | 3,245 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

String.Format on Japanese Windows

Hi,

I want to create dates in the following format: dd-MMM-yyyy e.g. 13-
Mar-2007

But are seeing some problems when running on a Japanese Windows XP.
Regional settings are set to JP.

Currently I am doing this
DateTime dat = DateTime.Now;
return String.Format(" {0:dd}-{0:MMM}-{0:yyyy}", date);

US Windows returns 27-Feb-2007
Japanese Windows return 27-2-2007

So I tried to come up with a solution to that fixes but could only
find half of the solution.
CultureInfo ci = new CultureInfo("en-US");
datestring = dat.ToString("G ", ci);
Console.WriteLi ne("en-US : " + datestring.Remo ve(datestring.I ndexOf('
')));

This works on both versions but changed the date format to mm/dd/yyyy

When I do this:
DateTime dt = DateTime.Parse( datestring);
Console.WriteLi ne(dt.ToString( "dd-MMM-yyyy"));
I am back to where I started!

Any help is much appeciated...

Regards
Lars Schouw

Feb 27 '07 #1
1 6525
Thort answer .. This does the stunt..
return date.ToString(" dd-MMM-yyyy", new CultureInfo("en-US"));

Long answer:

CultureInfo ci = new CultureInfo("en-US");
DateTime dtn = DateTime.Now;
string datestring = dtn.ToString("d ", ci);
Console.WriteLi ne("en-US : " + datestring);
DateTime dt = DateTime.Parse( datestring);
Console.WriteLi ne(dt.ToString( "dd-MMM-yyyy"));
// Japanese Windows
// en-US : 2/27/2007
// 27-2-2007

// US Windows
// en-US : 2/27/2007
// 27-Feb-2007

Console.WriteLi ne(dtn.ToString ("dd-MMM-yyyy", ci));
Console.WriteLi ne(dt.ToString( "dd-MMM-yyyy"), ci);
// Japanese Windows
// 27-Feb-2007
// 27-2-2007

// US Windows
// 27-Feb-2007
// 27-Feb-2007
On Feb 27, 4:04 pm, schou...@yahoo. com wrote:
Hi,

I want to create dates in the following format: dd-MMM-yyyy e.g. 13-
Mar-2007

But are seeing some problems when running on a Japanese Windows XP.
Regional settings are set to JP.

Currently I am doing this
DateTime dat = DateTime.Now;
return String.Format(" {0:dd}-{0:MMM}-{0:yyyy}", date);

US Windows returns 27-Feb-2007
Japanese Windows return 27-2-2007

So I tried to come up with a solution to that fixes but could only
find half of the solution.
CultureInfo ci = new CultureInfo("en-US");
datestring = dat.ToString("G ", ci);
Console.WriteLi ne("en-US : " + datestring.Remo ve(datestring.I ndexOf('
')));

This works on both versions but changed the date format to mm/dd/yyyy

When I do this:
DateTime dt = DateTime.Parse( datestring);
Console.WriteLi ne(dt.ToString( "dd-MMM-yyyy"));
I am back to where I started!

Any help is much appeciated...

Regards
Lars Schouw

Feb 27 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2587
by: Benoit Martin | last post by:
in my windows app, I have some japanese text that I load from a text file and display on a label. No matter what type of encoding I try to use on the text file, the text always comes up as a bunch of unreadable characters on my label. Are there settings/properties for a label on a windows form to be able to read japanese text? Is it when I raed the file that it gets screwed up (I use fileOpen and LineInput)? Looking for pointers here
6
7696
by: DFB_NZ | last post by:
Hi. I have had problems compiling a simple program that uses wstring. So....I wrote a small application that reads using char, fgetc etc in a text file and writes it out to another text file. The japanese was preserved in the outfile. I am a c++ programmer from M$ and I use TCHAR etc so I am no stranger to unicode on windows.
1
1552
by: jim figurski | last post by:
Hi, I have an American computer using windows XP. I recently bought a japanese game to help me learn japanese as I play. I installed the game sucessfully, but the letters are not displayed in "true" japanese. What I mean by that is, there are a few letters that actually are japanese combined with nonsensical characters. It resemebles the type of characters that are displayed if you select a japanese font other than the standard one...
4
1898
by: Thorben | last post by:
Hello group, does anybody knows a way to add Japanese language to a western language based application? Our software is switch-able between English and France. Now I got the job to add Japanese to the application. But when I put Japanese strings from MS Word per drag and drop into the text filed of a label I get only square characters. Has any body an Idea what I should do?
2
1699
by: Ajit | last post by:
Is it possible to have a web service name in localized string. Let's say, can I have a web service developed in C# having class name in Japanese? I am trying to build a web service as follows namespace Test2 { /// <summary> /// Summary description for Service1.
11
4773
by: prats | last post by:
I want to write a GUI application in PYTHON using QT. This application is supposed to take in Japanese characters. I am using PyQt as the wrapper for using QT from python. I am able to take input in japanese. But I am unable to display them back to GUI. It displays some junk characters Can anyone suggest me some way how to debug the issue. The code used for tranferring data from view to document is: " codec =...
1
3093
by: tony.pahl | last post by:
We are converting a data warehouse to a Unicode database to get ready for multilingual support. If we will have 95% of our data in English as we currently do, and less than 5% in other foreign languages including Japanese, it appears as if we would be best off using codepage of 1208 and UTF-8. We are thinking we would need to expand our 'char' and 'varchar' datatypes by four times to accommadate the Japanese data. Using 'varchar' should...
14
12200
by: rohitpatel9999 | last post by:
Hi While developing any software, developer need to think about it's possible enhancement for international usage and considering UNICODE. I have read many nice articles/items in advanced C++ books (Effective C++, More Effective C++, Exceptional C++, More Exceptional C++, C++ FAQs, Addison Wesley 2nd Edition) Authors of these books have not considered UNICODE. So many of their
10
3080
by: John Brown | last post by:
Hi there, Does anyone know how to go about reading/writing a type to a file in a language (culture) independent way. For instance, let's say you're dealing with the native "System.Drawing.Size" type on an English version of Windows. You use the "TypeConverter" for this structure to generate the string, say, "50, 75" which you then store in a file (or perhaps a DB). Now, the same value might later be read back in from this file on a...
0
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10484
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10251
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10027
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7565
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4141
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.