Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners convert date month and year into word using java
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Patel Dolar M.
convert date month and year into word using java
2 Answer(s)      2 years and 7 months ago
Posted in : Java Beginners


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


Advertisement
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 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 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
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 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
Java Get Month from Date
month from the current date using Java Application Language.  You can see... Java Get Month from Date     ... java.util package in the program code.   Java code to Get Month from Date
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
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
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.      
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.  Query... Mysql date month name       The Tutorial elaborate an example from Date Month Name in Mysql. To get
Mysql Date Month
Mysql Date Month       Mysql Date Month is used to find out the value of current month. Understand with Example The Tutorial illustrate an example from 'Mysql Date Month
Mysql Date Add Year
Mysql Date Add Year       Mysql Date Add Year explains to add the year to the particular... 'Mysql Date Add Year'. To graspe this example, we use Add('2008-12-15',INTERVAL 1
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
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     
Mysql Year of Date
Mysql Year of Date       Mysql Year of Date is used to return the current year of the table... (current_date) that return the current year of  the table. Current_Date
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 Previous Month
Mysql Date Previous Month       Mysql Date Previous Month is used to return the current and previous value of the month. Understand with Example The Tutorial illustrate an example
 

 

 

DMCA.com