473,387 Members | 1,760 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

½Ð±Ð¦³ÃöDate and Time Class

Nek
I want to add Date and Time to my Java Program , How can i get the system
time and date and pass to Java program ?

Many Many Thanks
~ ªÑ²¼»ù®æ¦³¤É¦³¶^, ¶R½æ*n¯à©Ó¾á*·ÀI ~

~ Samba, more than a low cost File and Printer server ~

-- Let us OpenSource --
Jul 18 '05 #1
2 8447
Nek wrote:
I want to add Date and Time to my Java Program , How can i get the
system time and date and pass to Java program ?


import java.text.SimpleDateFormat;
import java.util.Date;
....
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(sdf.format(new Date()));

*Or* when you are only interested in the system date and time in ms:

long sysTimeMs = System.currentTimeMillis();
JW

Jul 18 '05 #2
Nek
Hi JW ,

Many thanks !!

Ken :-)
"Janwillem Borleffs" <jw@jwscripts.com> ¼¶¼g©ó¶l¥ó·s»D:42**********************@news.euron et.nl...
Nek wrote:
I want to add Date and Time to my Java Program , How can i get the
system time and date and pass to Java program ?


import java.text.SimpleDateFormat;
import java.util.Date;
...
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(sdf.format(new Date()));

*Or* when you are only interested in the system date and time in ms:

long sysTimeMs = System.currentTimeMillis();
JW

~ ªÑ²¼»ù®æ¦³¤É¦³¶^, ¶R½æ*n¯à©Ó¾á*·ÀI ~

~ Samba, more than a low cost File and Printer server ~

-- Let us OpenSource --
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

50
by: Dan Perl | last post by:
There is something with initializing mutable class attributes that I am struggling with. I'll use an example to explain: class Father: attr1=None # this is OK attr2= # this is wrong...
9
by: Brian Henry | last post by:
If i inherite a queue class into my class, and do an override of the enqueue member, how would i then go about actually doing an enqueue of an item? I am a little confused on this one... does over...
9
by: David A. Osborn | last post by:
I have a set of classes that each have an enumeration in them, and based on dynamic input I need to access a different enumeration. For example Three classes Class_A, Class_B, and Class_C that...
13
by: thomasp | last post by:
I have written my first Class and am posting it to this newsgroup with hopes that I can get some feedback on what is right and what is wrong with it. All comments are welcome, but more interested...
5
by: Tony Johansson | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file called A One project that build a user control dll. Here we have a class called B One project...
12
by: mast2as | last post by:
Hi everyone I am working on some code that uses colors. Until recently this code used colors represented a tree floats (RGB format) but recently changed so colors are now defined as spectrum....
5
by: alan | last post by:
Hello world, I'm wondering if it's possible to implement some sort of class/object that can perform mapping from class types to strings? I will know the class type at compile time, like so:...
2
by: A.J. Bonnema | last post by:
Hi all, I just started using Python. I used to do some Java programming, so I am not completely blank. I have a small question about how classes get instantiated within other classes. I have...
36
by: Peter Olcott | last post by:
So far the only way that I found to do this was by making a single global instance of the container class and providing access to the contained class, through this single global instance. Are...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.