Long categoryId, Long remind, Rooms room, Long language_id,
Boolean isPasswordProtected, String password, Boolean isConnectedEvent,
String jNameTimeZone) {
try {
Appointment ap = new Appointment();
ap.setAppointmentName(appointmentName);
ap.setAppointmentLocation(appointmentLocation);
OmTimeZone omTimeZone = OmTimeZoneDaoImpl.getInstance().getOmTimeZone(jNameTimeZone);
String timeZoneName = omTimeZone.getIcal();
Calendar cal = Calendar.getInstance();
cal.setTimeZone(TimeZone.getTimeZone(timeZoneName));
int offset = cal.get(Calendar.ZONE_OFFSET) + cal.get(Calendar.DST_OFFSET);
log.debug("addAppointment appointmentstart :1: "+appointmentstart);
log.debug("addAppointment appointmentend :1: "+appointmentend);
log.debug("addAppointment jNameTimeZone :: "+jNameTimeZone);
log.debug("addAppointment offset :: "+offset);
appointmentstart = new Date(appointmentstart.getTime() - offset);
appointmentend = new Date(appointmentend.getTime() - offset);
log.debug("addAppointment appointmentstart :2: "+appointmentstart);
log.debug("addAppointment appointmentend :2: "+appointmentend);
ap.setAppointmentStarttime(appointmentstart);
ap.setAppointmentEndtime(appointmentend);
ap.setAppointmentDescription(appointmentDescription);
ap.setRemind(AppointmentReminderTypDaoImpl.getInstance().getAppointmentReminderTypById(remind));
ap.setStarttime(new Date());
ap.setDeleted("false");
ap.setIsDaily(isDaily);
ap.setIsWeekly(isWeekly);
ap.setIsMonthly(isMonthly);
ap.setIsYearly(isYearly);
ap.setLanguage_id(language_id);
ap.setIsPasswordProtected(isPasswordProtected);
ap.setPassword(password);
ap.setUserId(UsersDaoImpl.getInstance().getUser(userId));
ap.setAppointmentCategory(AppointmentCategoryDaoImpl.getInstance().getAppointmentCategoryById(categoryId));
ap.setRoom(room);
ap.setIsConnectedEvent(isConnectedEvent);
Object idf = PersistenceSessionUtil.createSession();
EntityManager session = PersistenceSessionUtil.getSession();
EntityTransaction tx = session.getTransaction();
tx.begin();
ap = session.merge(ap);
session.flush();
Long appointment_id = ap.getAppointmentId();
tx.commit();
PersistenceSessionUtil.closeSession(idf);
return appointment_id;