开发者

need help for swt.widgets.DateTime in eclipse-rcp for time format while accessing through the database

开发者 https://www.devze.com 2023-03-16 22:11 出处:网络
i have use the DateTimecontrol that show only time in my design view in PM, Am formatand user select only time from that one. i am using a column name timeFrom which i delcare a dataType tim开发者_如何

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 tim开发者_如何学JAVAe(7) in my mssql database. i can save it easily into the database as

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


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.................

0

精彩评论

暂无评论...
验证码 换一张
取 消