473,320 Members | 2,161 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,320 software developers and data experts.

Date and Time problem

Hello, im facing date and time problem. I want get a time in Date Type, with this format HH:mm:SS
i try to get new Date(), then format it as String. Then i use substring to get the time. Then i parse it as Date Type, and want to save it in database(database has a field called start_time, which is Date Type)
After i do this transaction and check with database, database show "1970-01-01 17:12:00".....Can anyone help me on that?Thanks in advanced
Mar 28 '08 #1
5 1889
Hello, im facing date and time problem. I want get a time in Date Type, with this format HH:mm:SS
i try to get new Date(), then format it as String. Then i use substring to get the time. Then i parse it as Date Type, and want to save it in database(database has a field called start_time, which is Date Type)
After i do this transaction and check with database, database show "1970-01-01 17:12:00".....Can anyone help me on that?Thanks in advanced
Can you tell me which class you used.. I mean the Date class or the Calendar class of the util package..Also can you a bit more clearer of the problem
Mar 28 '08 #2
Navdip
22
Can you tell me which class you used.. I mean the Date class or the Calendar class of the util package..Also can you a bit more clearer of the problem
Calendar c = new GregorianCalendar(1985,SEPTEMBER, 05);
String s = String.format("Date of birth Birthday: %1$tm %1$te,%1$tY", c);
System.out.println("Date of Bith is:- "+s);

u can change the date format like above code. u have to import following class and packages:- util.GregorianCalendar & util.Calendar.*;
Mar 28 '08 #3
JosAH
11,448 Expert 8TB
Calendar c = new GregorianCalendar(1985,SEPTEMBER, 05);
String s = String.format("Date of birth Birthday: %1$tm %1$te,%1$tY", c);
System.out.println("Date of Bith is:- "+s);

u can change the date format like above code. u have to import following class and packages:- util.GregorianCalendar & util.Calendar.*;
Please don't post spoon feeding code; I told you this before; you shouldn't do it.
Read the forum guidelines by pressing the 'Help' link near the top of this page.
Also use the code tags when you do have to post a code fragment, don't use
the bold tags. Also post correct code, not incorrect code; it is confusing at
least to the OP. Consider this a warning. You stand the risk of a ban.

kind regards,

Jos
Mar 28 '08 #4
Can you tell me which class you used.. I mean the Date class or the Calendar class of the util package..Also can you a bit more clearer of the problem
Im using java.util.Date, i convert the Time from String(HH:mm:SS format, value is 17:12:19) to Date, then it become "1970-01-01 17:12:00". Can i know why it become 1970-01-01?
Mar 29 '08 #5
Calendar c = new GregorianCalendar(1985,SEPTEMBER, 05);
String s = String.format("Date of birth Birthday: %1$tm %1$te,%1$tY", c);
System.out.println("Date of Bith is:- "+s);

u can change the date format like above code. u have to import following class and packages:- util.GregorianCalendar & util.Calendar.*;
Firstly im thank that you provide an example for me, i have tried, but it show Date, which not Time, any way, i appreciated u guys willing help :) further explaination on my problem, i have replied radhikams..
From the output, i can know that tm is month, te is day and tY is year, but may i know is it use tY, tm and te as default? can use other naming?and why need %1?
im newbie in java, pls forgive if i have ask stupid question.Thanks =)
Mar 29 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jay | last post by:
I previously posted this question under Visual Basic newsgroup, but was advised to re-post here. I'm hoping someone can help me solve an issue I'm having with VB.Net and Access 2000. Here's...
7
by: vnl | last post by:
I'm trying to run a SQL query but can't find any records when trying to select a certain date. Here's the sql: SELECT field 1, field2, date_and_time, FROM table1 WHERE date_and_time =...
1
by: Raghu | last post by:
Hello... I am running into a problem while running a query..can some1 help.. this is the query : ************** SELECT * from Table S where S.dtDate1 BETWEEN...
18
by: Robin Lawrie | last post by:
Hi again, another problem! I've moved from an Access database to SQL server and am now having trouble inserting dates and times into seperate fields. I'm using ASP and the code below to get the...
2
by: Riegn Man | last post by:
I have a problem with access and our time clocks. We have time clocks that put out a .log file with the badge swipes for everybody. There is one .log file for each day. I am pulling that data...
12
by: Assimalyst | last post by:
Hi, I have a working script that converts a dd/mm/yyyy text box date entry to yyyy/mm/dd and compares it to the current date, giving an error through an asp.net custom validator, it is as...
44
by: user | last post by:
Hi, Let's say I have 2 dates in the b/m format: Date 1 and date 2 How do I check whether Date2 is later than Date 1? Date1. 21-Nov-2006 09:00:00 PM
6
by: Geoff Cox | last post by:
Hello, at the moment I can add the combined date and time into MySQL using php $dt1 = date("Y-m-d H:i:s"); is it possible to add the date and time separately? I thought it might be
10
by: WebCM | last post by:
There is a function: http://paste.ubuntu.com/21865 It needs GMT date in YYYY-MM-DD HH:MM:SS format - in SQL: datetime. If date is the same as today, the function returns "Today". There is one...
16
by: W. eWatson | last post by:
Are there some date and time comparison functions that would compare, say, Is 10/05/05 later than 09/22/02? (or 02/09/22 format, yy/mm/dd) Is 02/11/07 the same as 02/11/07? Is 14:05:18 after...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.