Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6116863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:15:18+00:00 2026-05-23T15:15:18+00:00

i am using the DataType Time in my database it stores the data in

  • 0

i am using the DataType Time in my database it stores the data in the form as 01:23:14.0000000.
i am using dateTime controls of sWt as

DateTime dateTime = new DateTime(cmpGrid, SWT.BORDER | SWT.TIME);

i can save the Value of DateTime easily as

String hours =String.valueOf(timeTo.getHours());
String minutes =String.valueOf(timeTo.getMinutes());
String seconds =String.valueOf(timeTo.getSeconds());
objhallModel.setClose_time(hours + ":"+minutes + ":" + seconds);

For Editting purpose i need to set The time value in my design view For that i want to use

dateTime.setTime(hours, minutes, seconds);

it takes all hours, minutes, second in integer… can please anybody tell me how to set The time in DateTime of Database time value. thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:15:19+00:00Added an answer on May 23, 2026 at 3:15 pm

    I think you are using org.eclipse.swt.widgets.DateTime in your user interface and java.sql.Time to store in your database.

    I note that the javadoc of Time says:

    The date components should be set to
    the “zero epoch” value of January 1,
    1970 and should not be accessed.

    Therefore, I think you should set it as follows:

    DateTime dateTime; // you have this already
    
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(0); // set to zero epoch
    calendar.set(Calendar.HOUR, dateTime.getHours());
    calendar.set(Calendar.MINUTE, dateTime.getMinutes());
    calendar.set(Calendar.SECOND, dateTime.getSeconds());
    
    Time time = new Time(calendar.getTimeInMillis());
    

    The reverse operation (maybe this is what you want, I wasn’t sure from your question) would be:

    Time time; // you have this from your Database query
    DateTime dateTime; // you have this already or will create a new one
    
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(time.getTime());
    dateTime.setTime(calendar.get(Calendar.HOUR), calendar.get(Calendar.MINUTE),calendar.get(Calendar.SECOND));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have date and time stored in my database as MySQL DATETIME datatype. While
Can someone show me how to use the System.Numerics.BigInteger datatype? I tried using this
In .Net you can read a string value into another data type using either
In my current solution, I am converting a DateTime value, Time in my database
I am using MySQL database and I have a datetime field inside it. In
I am using the following code to get data from the database( from cs
I am working on an ajax-webmethod (using json) to save data in a database
How to display a time HH:MM format? Using SQL 2000 In my Database time
I have a column in database having datatype DATETIME . I want to set
What are the benefits of using the xml datatype versus storing the xml content

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.