Getting current time.

How do I print out the time in following format:Tuesday April 10 9:14:32 PST 2007Which package do I need to import first?
[142 byte] By [kevch27a] at [2007-11-27 0:36:21]
# 1
You'll want to look into the java.util package.Look into the Formatter classes, and look into the Date class, possibly.- Adam
guitar_man_Fa at 2007-7-11 22:45:40 > top of Java-index,Java Essentials,New To Java...
# 2
Check out SimpleDateFormat: http://java.sun.com/j2se/1.5.0/docs/api/java/text/SimpleDateFormat.html
tsitha at 2007-7-11 22:45:40 > top of Java-index,Java Essentials,New To Java...
# 3
Sorry, I've looked into java.util & java.text.SimpleDateFormat package but I'm still confused.How do I use these packages to grab Current System Date/Time?
kevch27a at 2007-7-11 22:45:40 > top of Java-index,Java Essentials,New To Java...
# 4

> Sorry, I've looked into java.util &

> java.text.SimpleDateFormat package but I'm still

> confused.

>

> How do I use these packages to grab Current System

> Date/Time?

When you create a new instance of java.util.Date, it automatically has the current system time.

- Adam

guitar_man_Fa at 2007-7-11 22:45:40 > top of Java-index,Java Essentials,New To Java...
# 5

if you're formatting requirement isn't strict and you don't want to play with the simpledateformatter - just create a new instance of Date and use its toString method - the toString method is overridden to provide a formatted date string (can't remember off the top of my head what the specific format is though).

cjmosea at 2007-7-11 22:45:40 > top of Java-index,Java Essentials,New To Java...
# 6

import java.text.SimpleDateFormat;

import java.util.Calendar;

.

.

.

.

Calendar cal = Calendar.getInstance();

SimpleDateFormat sdf = new SimpleDateFormat();

sdf.applyPattern("EEEEEE MMM d HH:mm:ss z yyyy");

System.out.println(sdf.format(cal.getTime()));

indiancometa at 2007-7-11 22:45:40 > top of Java-index,Java Essentials,New To Java...