1 /*
2 * SymmetricDS is an open source database synchronization solution.
3 *
4 * Copyright (C) Chris Henson <chenson42@users.sourceforge.net>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see
18 * <http://www.gnu.org/licenses/>.
19 */
20
21 package org.jumpmind.symmetric.util;
22
23 import java.util.Calendar;
24
25 import org.apache.commons.lang.time.DateUtils;
26 import org.jumpmind.symmetric.common.ParameterConstants;
27 import org.jumpmind.symmetric.service.IParameterService;
28
29 public class AfterMidnightTimeSlot {
30
31 int minutesAfterMidnight;
32
33 public long getMillisecondsUntilTargetTime() {
34 Calendar midnight = DateUtils.truncate(Calendar.getInstance(), Calendar.DATE);
35 midnight.add(Calendar.DATE, 1);
36 return midnight.getTime().getTime() - System.currentTimeMillis() + minutesAfterMidnight
37 * DateUtils.MILLIS_PER_MINUTE;
38 }
39
40 public void setParameterService(IParameterService s) {
41 this.minutesAfterMidnight = s.getInt(ParameterConstants.JOB_SYNCTRIGGERS_AFTER_MIDNIGHT_MIN);
42 }
43
44 }