Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Convert Long to Date 
 

In this section, you will learn to convert a long into a date format. Java provides some methods and APIs to solved it.

 

Convert Long to Date

                         

In this section, you will learn to convert a long into a date format. Java provides some methods and APIs to solved it. 

Description of program:

This example helps you in converting a  long value into a Date. The getDateInstance() method is a time formatter with the given formatting style for the default locale. And the getTimeInstance(int style) method is used to get the time formatter with the given formatting style for the default locale. Here style gives the formatting style.

Some other styles are:

  1. FULL
  2. LONG
  3. MEDIUM
  4. SHORT
  5. DEFAULT

[Note: Its value is MEDIUM.]

 

Here is the code of program:

import java.util.*;
import java.text.*;
public class LongToDate {
   public static void main(String[] args)throws Exception {
      Date date = new Date();
      DateFormat dataformat =  DateFormat.
getDateInstance(DateFormat.LONG);
     
      String s4 = dataformat.format(date);
       System.out.println(dataformat.format(date));    
    } }    

Output of this program:

C:\date>javac LongToDate.java
C:\date>java LongToDate
June 12, 2007

Download this example.

                         

» View all related tutorials
Related Tags: java c ide array class div io matrix get vi this id define ping for program to learn ram ear

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

2 comments so far (
post your own) View All Comments Latest 10 Comments:

Hi

with out using new Date instance how to convert long to date?

Posted by prasad on Thursday, 06.21.07 @ 14:48pm | #19875

Hi,

using TimeStamp how to convert date to long?
pls any one know send me example code.

Posted by prasad on Thursday, 06.21.07 @ 14:41pm | #19874

Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.