在通过数据库访问时,需要eclipse-rcp中swt.widgets.DateTime的时间格式帮助

时间:2023-01-12 14:25:49

i have use the DateTime control that show only time in my design view in PM, Am format and user select only time from that one. i am using a column name timeFrom which i delcare a dataType time(7) in my mssql database. i can save it easily into the database as

我使用了DateTime控件,它在我的设计视图中仅显示PM,Am格式和用户只选择该时间的时间。我正在使用列名timeFrom,我在我的mssql数据库中查看dataType time(7)。我可以轻松地将其保存到数据库中

objBookingModel.settimeFrom(timeFrom.getHours() + ":"
                + timeFrom.getMinutes() + ":" + timeFrom.getSeconds());

Suppose i enter 10:54:44 pm in the design view it is stored in the database as 22:54:44. now please Help how to format 22:54:44 as 10:54:44 PM when i want to show back it in design view from the databse. should i have to use timefrom.setTime( );?

假设我在设计视图中输入10:54:44 pm它以22:54:44存储在数据库中。现在请帮助如何格式化22:54:44格式为10:54:44 PM,当我想在数据库的设计视图中显示它。我应该使用timefrom.setTime();?

1 个解决方案

#1


3  

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));

This one was the answer i worked with might be helpful to thers.................

这个是我工作的答案可能对他们有帮助.................

#1


3  

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));

This one was the answer i worked with might be helpful to thers.................

这个是我工作的答案可能对他们有帮助.................