Programming and Webmasters forum
HomeSearchRecent PostsLoginRegisterContact Us

Username  
Password

Pages: [1]   Go Down
 
  Email this topic  |  Print
0 Members and 1 Guest are viewing this topic.

Current Date and time using Java

 
webmaster forum
nikon  Offline
 
New Coder
Posts: 20
Topics: 13
September 11, 2008, 07:28:33 PM

hello all

I want to fetch current date and time using java in java applet so i can implement in my html page using applet. How can I do that?

Please help
 
webmaster forum
polas  Offline
*
 
Code Guru
Gender: Male
Posts: 1296
Topics: 79
WWW
September 12, 2008, 02:39:26 AM

using java.util.Calendar

 int year = cal.get(Calendar.YEAR);
  int month = cal.get(Calendar.MONTH);
  int date = cal.get(Calendar.DATE);

Have a look at :

http://java.sun.com/j2se/1.4.2/docs/api/java/util/Calendar.html

Mesham Type Oriented Parallel Programming Language
 
webmaster forum
 
New Coder
Posts: 49
Topics: 14
September 16, 2008, 03:33:48 AM

Hi with the use of Util.Calendar you can get the current Date and Time. Below is the code sample.

import java.util.Calendar;
import java.text.SimpleDateFormat;

public class DateUtils {
  public static final String DATE_FORMAT_NOW = "yyyy-MM-dd HH:mm:ss";

  public static String now() {
    Calendar cal = Calendar.getInstance();
    SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
    return sdf.format(cal.getTime());

  }

  public static void  main(String arg[]) {
    System.out.println("Now : " + DateUtils.now());
  }
}



use the below link to know more details

http://www.javafaq.nu/java-example-code-288.html
http://www.rgagnon.com/javadetails/java-0106.html
 
webmaster forum
vijay12  Offline
 
Regular Coder
Posts: 67
Topics: 33
January 03, 2009, 11:43:13 AM

Hi friend. Its easy to get the current date and time using Java. Take a look here, http://www.roseindia.net/java/java-get-example/get-date-now.shtml to get the source code.
« Last Edit: January 03, 2009, 12:07:44 PM by theone759 »
 
  Email this topic  |  Print
Pages: [1]   Go Up
 
Jump to:  



Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC


Google visited last this page September 09, 2010, 03:44:01 PM