Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML


 
  
 
Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML
 

 
Facing Programming Problem?
Ask Questions?, Browse Latest Questions, Question-Answer Guidelines
Java
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

Convert Date to Long

                         

In this section you will learn to convert the date into a long format. The java.util package provides the functionality to convert a date type into a long type. 

Description of program:

The following program helps you in converting a date into a long type. First of all you need a date that needs to be converted. The DateFormat is a constructor to create a new  date format. The getTime() method is used to convert the given date into a long type. This method returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object. which is of long type.

 

 Here is the code of program:

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

public class DateToLong {
  public static void main(String[] args) {
    try {
      String str_date="11-June-07";
      DateFormat formatter ; 
      Date date ; 
      formatter = new SimpleDateFormat("dd-MMM-yy");
      date = (Date)formatter.parse(str_date)
      long longDate=date.getTime();
      System.out.println("Today is " +longDate );
    }
    catch (ParseException e){
      System.out.println("Exception :"+e);   
    }
  }
}

 Output of this program:

C:\date>javac DateToLong.java
C:\date>java DateToLong
Today is 1181500200000

Download this example.

                         

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 
Latest Searches:
mysql blob
Insert an array list o
javabean program
Merge Sort In Javascri
write a program to tes
java applets
x509
connect a program writ
extract
Create XML file from f
lucene
Two Dimensional Array
file input output
username and password
HSSF clone cell
interview question
JSF 2
FileInputStream
code for how connect j
hibernate many to many
source code for chat p
set()mutator method
Tree Grid using flex
?���??���?
techiques to use subst
Photoshop Textures and
abstract
flex tutorial
jsp servlet basics
intranet applications
highlighting and dehig
j2me combo example
�����????�
String to array in jav
how to override...ng i
infix
factory method
call ejb j2ee5
message dialog
java write file line b
stopping actionPerform
jdbc with ms access
Applet JSP Programing
iterator
action form struts
swing program
create file folder
requestDispatcher
3DS MAX Effects Advanc
tiles2
delete data in mysql d
Flash Interactivity Sc
strust example
update checkbox row in
what is static inner c
How to Use JFrame in J
ttcn
jpa quries
Maya Effects Interpart
Photoshop Text Effects
array list
c:out in var of c:fore
techiques to use subst
java.nio
Scanner
how to traverse throug
File InputStream
Flash Math Physics Fla
struttutorial
java / objects
Javascript Links and B
DispatchAction
toString
ASP Ad Management Crea
struts formfile
date jsp
Submit comments in dat
Create PDF file exampl
session
API
Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

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 | 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.