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



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

Have Programming Question? Ask it here!
 
 
 


Patel Dolar M.
convert date month and year into word using java
2 Answer(s)      2 years and 5 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:37 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:38 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 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
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 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
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
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
Mysql Date Get Year
Mysql Date Get Year       Mysql Date Get Year is the way of retrieving the current year. Understand with Example The Tutorial illustrate an example from 'Mysql Date Get
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
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
Mysql Date Convert
format according to the day,date,month and year.  SELECT DATE... Mysql Date Convert       The 'Mysql Date Convert' show you the mean to format the Date
Mysql Date Query
Mysql Date Query       Mysql Date Query Date Query is used to return the current date, month and year... to return you the current date, month and year as fieldname current_date 
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
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
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
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
,date,month and year as respectively field name. mysql> select..., -> date_format(now(),'%M')as month, -> date_format(now(),'%Y')as Year... | date | month | Year
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.  YEAR(date) : This method returns the year
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
Convert String into date
in java. Example:  Code to convert String to Date in java. import...Convert String into date In this example we are going to convert String... convert a string into Date format. It also provide some of the methods like
PHP Date add 1 month
PHP Date add 1 month This example shows you how one month can be added... to add 1 month: <?php //PHP Example code to add one moth to a date... month"); echo "After adding one month: ".date('l dS \o\f F Y
Convert Text To Word
Convert Text To Word       In this example, You will learn how to convert text to word file. Here, we... file. This program converts the text to word file by using FileOutputStream("
convert date time to int
convert date time to int  convert date time to int
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
Advertisements
 

 

 

DMCA.com