?
Solved

TIME

Posted on 2003-03-31
6
Medium Priority
?
165 Views
Last Modified: 2010-05-18
anybody can provide the codes to get current time and date?
0
Comment
Question by:kirov
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 4

Accepted Solution

by:
thanassis earned 200 total points
ID: 8237246
you ca use the class Date as follows:

<%java.util.Date d = new Date();%>
<%=d%>
0
 
LVL 11

Expert Comment

by:fargo
ID: 8237603
Hii,

java.text.SimpleDateFormat dFormat=new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String today = dFormat.format(new java.util.Date());

Use any format u want to extract the date and time.
Hope this helps
happy working
fargo

0
 
LVL 4

Expert Comment

by:Binary1
ID: 8240379
java.util.GregorianCalendar can be used if you need to access the specific date/time fields, Month, day, hour, etc.
0
 
LVL 3

Expert Comment

by:r_a_j_e_s_h
ID: 8243546
<%@ page contentType="text/html" %>

<%@ page language="java" import="java.util.*" %>

<%
Calendar cal = new GregorianCalendar();
          // Get the components of the date
int era = cal.get(Calendar.ERA);
         // 0=BC, 1=AD
int year = cal.get(Calendar.YEAR);  
         // 2002
int month = cal.get(Calendar.MONTH);
          // 0=Jan, 1=Feb, ...
int day = cal.get(Calendar.DAY_OF_MONTH);  
          // 1...
int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
         // 1=Sunday, 2=Monday, ...

java.util.Date d1=new Date(year,month,day);
out.println(d1);
%>
0
 
LVL 35

Expert Comment

by:girionis
ID: 10061007
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Points to thanassis

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

girionis
EE Cleanup Volunteer
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introducing Priority Question, our latest feature.
In this modest contribution, I want to share with the IT community (especially system administrators, IT Support Engineers and IT Help Desks) about Windows crashes/hangs and how to deal with these particular problems.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month14 days, 9 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question