Home » Category » Java Programming

Java Programming: Date and Time Class

206| Wed, 26 Dec 2007 22:48:00 GMT| nek| Comments (2)
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

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

-- Let us OpenSource --

Keywords & Tags: date, time, class, java, programming

URL: http://java.itags.org/java-programming/332358/
 
«« Prev - Next »» 2 helpful answers below.
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

janwillemborleffs | Wed, 26 Dec 2007 22:49:00 GMT |

Hi JW ,

Many thanks !!

Ken :-)

"Janwillem Borleffs" <jw...jwscripts.com> glsD:4285d5b0$0$6770$dbd41001...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 --

nek | Wed, 26 Dec 2007 22:50:00 GMT |

Java Programming Hot Answers

Java Programming New questions

Java Programming Related Categories