Click here to Skip to main content
15,867,453 members
Articles / Programming Languages / C#
Article

Indian Number & Date Format

Rate me:
Please Sign up or sign in to vote.
3.17/5 (19 votes)
29 Aug 2012CDDL3 min read 114.1K   1.8K   41   55
A control for Indian number format, converts number to words, Hindi words, comma style and Indian date processor

This article is a sponsored article. Articles such as these are intended to provide you with information on products and services that we consider useful and of value to developers

Image 1

Image 2

Introduction

Indian.dll control is a control for applications which need the data to be formated in Indian formats/national language (Hindi). It's very useful if you are working with windows (which still does not support Indian formats). This will format the data (numbers) in Indian comma style (eg. 9,999/-), Indian words in English as well as Hindi(eg. one lac only) and formats the date independent of system settings to dd-MM-yyyy (not for display, but storage and calculations). Furthermore, it displays the numbers with the new currency symbol for the rupee.

This program is also useful if you have data in Indian format, to be converted in to integer

Using the Code

To use this control, reference the control and start formatting the data, to suit your needs.

To convert data in Indian format to integer

//
// There is a function defined called getVal in the namespace Indian.IndianCurrency
//

int i=Indian.IndianCurrency.getVal("Rs. 99,999/-");

// This will return 99999 to the integer

To convert date from system format to Indian format

//
// There is a function defined called date in the namespace Indian.IndianDate
//

int i=Indian.IndianDate.date("1-2-3");

// This will return 01-02-2003 (dd-MM-yyyy)
//
// To get the data in other format, you can specify the "Input Format" to get desired result
// For example:

int i=Indian.IndianDate.date("1/2/3", "MM/dd/yyyy");

// This will return 01/02/2003 equivelent to 02-01-2003 (dd-MM-yyyy)

To create a new translation in the XML file.

//
// Section Encapsulates the language information
//

 < Section Name="Marathi" > ... < / section >

// Fill in the all the values for the "Key Name"
//
// For example: 

< Key Name="Rupees" Value="रुपये" / >

// Save the file in UTF-8 encoding. Supports multiple languages and hence no 
// limit on the number of sections that can be created.

Download a sample program to play with it, you will see some more examples there to reach all results as shown in images above. 

Points of Interest

I was baffled when I used to get different results of my invoice program from the same data. This was, since all the storage was made in system format. Since then I learnt that one must follow a rule to save date (at least) in a particular format itself. After using it in several programs, I learnt it to be very useful for many programers and hence I decided to write this article.

On this page apart from the images I have not used rupee symbol due to font unavailability on all systems but program would work across all systems.  

You may and you may not use the font provided to display the rupee symbol. Since this is a unicode character you will be able to see it on all fonts with the available graph for the symbol.

This program is free to use and without source. You may wish to drop me a line of where it is being used.

Limitations

  • No source for you to edit.

History

Version 1.6.0: First public posting.

Version 1.7.5: Few enhancements and fixes, decimal included.

Version 1.8.0: Few enhancements and fixes.

Version 2.0.0: Few enhancements and fixes. Included Marathi ("mr") as a langauge & added support for new rupee symbol. Thanks to Shri Javed Patel for Marathi translation.

Version 2.1.0: Many fixes and a few enhancements. A nearly new written code.

Version 2.5.0: Support for translation file. Now support for any language can be added by user by editing the translation file.

Version 3.0.0: Few enhancements and fixes. "Marathi" language is moved out to translation file.

Contents of Download

  • The solution built in VC# Express 2010
  • The usable files in your program:
    • Indian.dll
    • Settings.dll
    • langFor.xml

Planned Update

  • No Plans to update this program further until I get a really new idea haunts my mind.

License

This article, along with any associated source code and files, is licensed under The Common Development and Distribution License (CDDL)


Written By
Web Developer
India India
I am a computer engineer doing business at my city. I love to program is also engaged in part time programing. Normaly, work for fun and most of the time free of charge.

Comments and Discussions

 
GeneralRe: What do you mean by Windows does not support it? Pin
Mihai Nita6-Mar-07 7:04
Mihai Nita6-Mar-07 7:04 
GeneralExcellent !!! Pin
ht75-Mar-07 1:50
ht75-Mar-07 1:50 
GeneralRe: Excellent !!! Pin
hprahul5-Mar-07 14:18
hprahul5-Mar-07 14:18 
GeneralRe: Excellent !!! Pin
ht75-Mar-07 18:41
ht75-Mar-07 18:41 
GeneralRe: Excellent !!! Pin
hprahul6-Mar-07 3:04
hprahul6-Mar-07 3:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.