Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Indian Number & Date Format

0.00/5 (No votes)
29 Aug 2012 1  
A control for Indian number format, converts number to words, Hindi words, comma style and Indian date processor

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here