convert date month and year into word using java

convert date month and year into word using java

convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.

View Answers

March 26, 2012 at 4:39 PM

import java.util.*;
import java.text.*;

public class DateToWords {
        String string;
        String st1[] = { "", "one", "two", "three", "four", "five", "six", "seven",
                        "eight", "nine", };
        String st2[] = { "hundred", "thousand"};
        String st3[] = { "ten", "eleven", "twelve", "thirteen", "fourteen",
                        "fifteen", "sixteen", "seventeen", "eighteen", "ninteen", };
        String st4[] = { "twenty", "thirty"};

        public String getMonth(int month) {
           return new DateFormatSymbols().getMonths()[month-1];
        }

        public String convert(int number) {
                int n = 1;
                int word;
                string = "";
                while (number != 0) {
                        switch (n) {
                        case 1:
                                word = number % 100;
                                pass(word);
                                if (number > 100 && number % 100 != 0) {
                                        show("and ");
                                }
                                number /= 100;
                                break;

                        case 2:
                                word = number % 10;
                                if (word != 0) {
                                        show(" ");
                                        show(st2[0]);
                                        show(" ");
                                        pass(word);
                                }
                                number /= 10;
                                break;

                        case 3:
                                word = number % 100;
                                if (word != 0) {
                                        show(" ");
                                        show(st2[1]);
                                        show(" ");
                                        pass(word);
                                }
                                number /= 100;
                                break;

                        case 4:
                                word = number % 100;
                                if (word != 0) {
                                        show(" ");
                                        show(st2[2]);
                                        show(" ");
                                        pass(word);
                                }
                                number /= 100;
                                break;

                        case 5:
                                word = number % 100;
                                if (word != 0) {
                                        show(" ");
                                        show(st2[3]);
                                        show(" ");
                                        pass(word);
                                }
                                number /= 100;
                                break;

                        }
                        n++;
                }
                return string;
        }

March 26, 2012 at 4:40 PM

continue....

public void pass(int number) {
                int word, q;
                if (number < 10) {
                        show(st1[number]);
                }
                if (number > 9 && number < 20) {
                        show(st3[number - 10]);
                }
                if (number > 19) {
                        word = number % 10;
                        if (word == 0) {
                                q = number / 10;
                                show(st4[q - 2]);
                        } else {
                                q = number / 10;
                                show(st1[word]);
                                show(" ");
                                show(st4[q - 2]);
                        }
                }
        }

        public void show(String s) {
                String st;
                st = string;
                string = s;
                string += st;
        }

        public static void main(String[] args) {
                DateToWords num = new DateToWords();
                  SimpleDateFormat dateFormatter = new SimpleDateFormat("dd/MM/yyyy");
                  ParsePosition parsePosition = new ParsePosition(0);
                  Calendar cal = Calendar.getInstance();
                  cal.setTime(dateFormatter.parse("26/3/2012",new ParsePosition(0)));
                  int day  = cal.get(Calendar.DATE);
                  int month  = cal.get(Calendar.MONTH) + 1;
                  int year = cal.get(Calendar.YEAR);
                  System.out.println(num.convert(day)+" "+num.getMonth(month)+" "+num.convert(year));
        }
}









Related Tutorials/Questions & Answers:
convert date month and year into word using java
convert date month and year into word using java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
convert date month and year into word using java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
Advertisements
convert date month and year into word using java
convert date month and year into word using java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
convert date month and year Java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
convert date month and year  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Convert Date Month format  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Java Date Month Format  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Convert Date Format  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Match Date format  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Date Format in Jave  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Basic format for Date and Month  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
convert date month and year into word using java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls...;continue.... public void pass(int number) { int word, q
convert date month and year into word using java
convert date month and year into word using java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls...;continue.... public void pass(int number) { int word, q
Add year to Date without using Calendar in java
Add year to Date without using Calendar in java  how could i add a year to a date function without using calendar functions
How to get month name from date(like-25/06/2012) using java?
How to get month name from date(like-25/06/2012) using java?  How to get month name from date(like-25/06/2012) using java
how to display(update) current date and month in select box on selecting the year.
how to display(update) current date and month in select box on selecting the year.  how to display(update) current date and month in select box on selecting the year
Java Get Month from Date
month from the current date using Java Application Language. You can see... Java Get Month from Date     ... tutorial of "How to get month from a Date?": Java code to Get Month
Java Convert date to words
of the date (the day, the month, the year), and convert them individually using...Java Convert date to words In this tutorial, you will learn how to convert date into words. Just like a number, you can also convert a date into words. Here
Java code to convert pdf file to word file
Java code to convert pdf file to word file  How to convert pdf file to word file using Java
Addintion in year fields of sql date in a java page
Addintion in year fields of sql date in a java page  In my database...("Year: " + simpleDateformat.format(date)); String k= simpleDateformat.format(date); } But I have to add 4 with the year value
Convert Date To Calendar
into Calendar. Here we are using format method to convert date into string. ... fields such as YEAR, MONTH, DAY, HOUR, and so on. A Date object represents... Convert Date To Calendar     
How to merge two word document using java
How to merge two word document using java   how to merge two word document using java
How to merge two word document using java
How to merge two word document using java   how to merge two word document using java
Mysql date month name
;date_format(now ( ),%M') return you the current month of the year. ADS... Mysql date month name       The Tutorial elaborate an example from Date Month Name in Mysql. To get
How to convert date to string in Java?
How to convert date to string in Java?  Hello developers, I have java.util.Date object and it has to be converted to date format. How to convert date to string in Java? Thanks   Hi, To convert java.util.Date object
Mysql Date Month
Mysql Date Month       Mysql Date Month is used to find out the value of current month. Understand with ExampleADS_TO_REPLACE_1 The Tutorial illustrate an example from 'Mysql Date
Mysql Date Add Year
Mysql Date Add Year       Mysql Date Add Year explains to add the year to the particular... an example from 'Mysql Date Add Year'. To graspe this example, we use Add
Java get year from date
Java get year from date     ... showing the format of year. The method simpleDateformat.format(date) formats a Date into a date/time string and returns the year.  ADS_TO_REPLACE_1  
Mysql Year of Date
Mysql Year of Date       Mysql Year of Date is used to return the current year of the table... from 'Mysql Year of Date'. To understand and grasp the example we use
Convert String to Date
additional functions. It allows the interpretation of date in year, month, day, hour... All methods of  Date either accept or return values in year, month, day..., date) / GregorianCalendar(year + 1900, month, date), Calendar.set(year + 1900
Mysql Date Previous Month
Mysql Date Previous Month       Mysql Date Previous Month is used to return the current and previous value of the month. Understand with ExampleADS_TO_REPLACE_1 The Tutorial
convert word document to pdf
convert word document to pdf  Hi, Could you please help me write a java code that converts the word docuemnt into PDF? I have to save the generated... a java beginner. Please help out in this. Thanks in advance. Regards, Sindhu
Mysql Date Query
Mysql Date Query       Mysql Date Query Date Query is used to return the current date, month and year... is used to return you the current date, month and year as fieldname current
Mysql Date Convert
, date, month and year.     2008-12-07':- This is the date which... The Query below return you the date format according to the day,date,month and year... Mysql Date Convert      
Write a java program to display the season given the month using switch case
Write a java program to display the season given the month using switch case  Write a java program to display the season given the month using switch case
how to translate english word to marathi using java
how to translate english word to marathi using java  I want to translat english word to marathi,how i can develop a code for that ,please sajest me
Java date add year
Java date add year In this tutorial, you will learn how to add years to date... to represent the current date. Then using the method add() of Calendar class, we have added 4 years to the calendar and using the Date class, we have got the date
Mysql Date Get Year
Mysql Date Get Year       Mysql Date Get Year is the way of retrieving the current year... 'Mysql Date Get Year'. To understand and grasp this example, we use
Auto complete of word search using ajax with java
Auto complete of word search using ajax with java  I want to display the list of words when I type the first letter of the word in a text box. I am using jsp to design the form. I want ajax sample to achieve this feature. Its
Auto complete of word search using ajax with java
Auto complete of word search using ajax with java  I want to display the list of words when I type the first letter of the word in a text box. I am using jsp to design the form. I want ajax sample to achieve this feature. Its
Mysql Date Functions
:- The Query return you the current day,date,month and year as respectively field name... +--------+------+----------+------+ | Day | date | month | Year... year and current month. Understand with ExampleADS_TO_REPLACE_1 The Tutorial
Java Get Method
is going to show the date details.. including year, date and month etc... and year from date in Java?": ADS_TO_REPLACE_2 Code for Java Get... Java Get Method   
Determining If a Year is a Leap Year in Java
Determining If a Year is a Leap Year in Java  ... an extra day. In the leap year, February month contains 29 days since normally February month has 28 days. The year which is completely divided by 4
java yesterday - Date Calendar
to make date sustract, the result is to make 1 month and 1 day like this, right. now how about 1 year and 1 month? And Can help me to using Date Calender what...); String df1 = cur_date + "-" + cur_month + "-" + cur_year; SimpleDateFormat
How to convert date to UTC format in Java?
How to convert date to UTC format in Java?  Hi, What is UTC Date format and How to convert date to UTC format in Java? I need simple to learn... of world. You can use Java program to convert the date in UTC String
convert current date into date format
convert current date into date format  How to get current date and convert into date format in Java or PHP
Merge multiple jasper file to one word Doc using java
Merge multiple jasper file to one word Doc using java   how to Merge multiple jasper file to one word Doc using java
PHP convert week number to days or month - PHP
PHP convert week number to days or month  Small, simple and easy code that can do following task: 1.Convert Week Numbers to Month 2.Convert Week to Date Generally, we use the date time object in PHP to convert the date
JDBC : Get year from Date
JDBC : Get year from Date In this section, you will learn how to get year from date. Get year from Date : In MySql you can get year from the given Date by using year() function.ADS_TO_REPLACE_1  YEAR(date) : This method returns
Using poi hwpf,how to create table in word document. - Java Beginners
Using poi hwpf,how to create table in word document.  Can you please tell me how to create a table in the word document in java using Apache poi hwpf.its very urgent.Please send some sample code.Thanks in advance

Ads