|
Attention! Read the forum rules carefully before posting a topic.
Try to find an answer in Wiki before asking a question. Submit programming questions in this forum only. Off topics are strictly forbidden.
Any topics which do not satisfy these rules will be deleted.
Execution only after a certain Date and Time |
Jameswter
|
Post subject: Execution only after a certain Date and Time |
Post rating: 0
|
Posted: Sun 04 Jun, 2017, 12:21
|
|
User rating: 0
Joined: Tue 06 Sep, 2016, 11:04 Posts: 20 Location: United Kingdom,
|
Hi,
Say I want to execute something inside onTick but only at or after a certain date and time. Example: after 15.06.2017, 15:30:59.
How can I do it? Please show the exact if statement I need to use.
Thanks
|
|
|
|
 |
Jameswter
|
Post subject: Re: Execution only after a certain Date and Time |
Post rating: 0
|
Posted: Tue 06 Jun, 2017, 06:29
|
|
User rating: 0
Joined: Tue 06 Sep, 2016, 11:04 Posts: 20 Location: United Kingdom,
|
I see nobody get answers here.
Nobody care about this forum?
|
|
|
|
 |
Armineq
|
Post subject: Re: Execution only after a certain Date and Time |
Post rating: 0
|
Posted: Fri 07 Jul, 2017, 18:59
|
|
User rating: 0
Joined: Tue 15 Sep, 2015, 20:14 Posts: 4 Location: Poland,
|
private Boolean validTimeOfOrder (long time) { Boolean ret = false; Calendar calendarNow = Calendar.getInstance(); Calendar calendarFrom = Calendar.getInstance(); Calendar calendarTo = Calendar.getInstance(); calendarNow.setTimeInMillis(time); int year = calendarNow.get(Calendar.YEAR); int month = calendarNow.get(Calendar.MONTH) + 1; // Note: zero based! int day = calendarNow.get(Calendar.DAY_OF_MONTH); calendarFrom.set(year, month - 1, day, 5, 29, 59); calendarTo.set(year, month - 1, day, 22, 30, 00); if (calendarNow.getTime().getTime() < calendarTo.getTime().getTime() && calendarNow.getTime().getTime() > calendarFrom.getTime().getTime()) { // handel tylko w dni powszedne if (day != Calendar.SATURDAY && day != Calendar.SUNDAY) { ret = true; } } return ret; }
|
|
|
|
 |
|
Pages: [
1
]
|
|
|
|
|