Search in sources :

Example 26 with LocalTime

use of org.joda.time.LocalTime in project Auto.js by hyb1996.

the class TimedTaskSettingActivity method setUpTime.

private void setUpTime() {
    mDisposableTaskDate.setText(DATE_FORMATTER.print(LocalDate.now()));
    mDisposableTaskTime.setText(TIME_FORMATTER.print(LocalTime.now()));
    if (mTimedTask == null) {
        mDailyTaskRadio.setChecked(true);
        return;
    }
    if (mTimedTask.isDisposable()) {
        mDisposableTaskRadio.setChecked(true);
        mDisposableTaskTime.setText(TIME_FORMATTER.print(mTimedTask.getMillis()));
        mDisposableTaskDate.setText(DATE_FORMATTER.print(mTimedTask.getMillis()));
        return;
    }
    LocalTime time = LocalTime.fromMillisOfDay(mTimedTask.getMillis());
    mDailyTaskTimePicker.setCurrentHour(time.getHourOfDay());
    mDailyTaskTimePicker.setCurrentMinute(time.getMinuteOfHour());
    if (mTimedTask.isDaily()) {
        mDailyTaskRadio.setChecked(true);
    } else {
        mWeeklyTaskRadio.setChecked(true);
        for (int i = 0; i < mDayOfWeekCheckBoxes.size(); i++) {
            mDayOfWeekCheckBoxes.get(i).setChecked(mTimedTask.hasDayOfWeek(i + 1));
        }
    }
}
Also used : LocalTime(org.joda.time.LocalTime)

Example 27 with LocalTime

use of org.joda.time.LocalTime in project Auto.js by hyb1996.

the class TimedTaskSettingActivity method createWeeklyTask.

private TimedTask createWeeklyTask() {
    long timeFlag = 0;
    for (int i = 0; i < mDayOfWeekCheckBoxes.size(); i++) {
        if (mDayOfWeekCheckBoxes.get(i).isChecked()) {
            timeFlag |= TimedTask.getDayOfWeekTimeFlag(i + 1);
        }
    }
    if (timeFlag == 0) {
        Toast.makeText(this, R.string.text_weekly_task_should_check_day_of_week, Toast.LENGTH_SHORT).show();
        return null;
    }
    LocalTime time = new LocalTime(mDailyTaskTimePicker.getCurrentHour(), mDailyTaskTimePicker.getCurrentMinute());
    return TimedTask.weeklyTask(time, timeFlag, mScriptFile.getPath(), ExecutionConfig.getDefault());
}
Also used : LocalTime(org.joda.time.LocalTime)

Example 28 with LocalTime

use of org.joda.time.LocalTime in project Auto.js by hyb1996.

the class TimedTaskSettingActivity method showDisposableTaskTimePicker.

@Click(R.id.disposable_task_time_container)
void showDisposableTaskTimePicker() {
    LocalTime time = TIME_FORMATTER.parseLocalTime(mDisposableTaskTime.getText().toString());
    new TimePickerDialog(this, (view, hourOfDay, minute) -> mDisposableTaskTime.setText(TIME_FORMATTER.print(new LocalTime(hourOfDay, minute))), time.getHourOfDay(), time.getMinuteOfHour(), true).show();
}
Also used : TimedTaskManager(com.stardust.scriptdroid.timing.TimedTaskManager) TimePickerDialog(android.app.TimePickerDialog) LinearLayout(android.widget.LinearLayout) Bundle(android.os.Bundle) RadioButton(android.widget.RadioButton) LocalTime(org.joda.time.LocalTime) TaskReceiver(com.stardust.scriptdroid.timing.TaskReceiver) R(com.stardust.scriptdroid.R) RadioGroup(android.widget.RadioGroup) AfterViews(org.androidannotations.annotations.AfterViews) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) ScriptIntents(com.stardust.scriptdroid.external.ScriptIntents) DatePickerDialog(android.app.DatePickerDialog) CheckBox(android.widget.CheckBox) Toast(android.widget.Toast) Menu(android.view.Menu) View(android.view.View) TimedTask(com.stardust.scriptdroid.timing.TimedTask) Build(android.os.Build) ScriptFile(com.stardust.scriptdroid.model.script.ScriptFile) DateTimeFormat(org.joda.time.format.DateTimeFormat) CompoundButton(android.widget.CompoundButton) DateTimeFormatter(org.joda.time.format.DateTimeFormatter) TextUtils(android.text.TextUtils) LocalDateTime(org.joda.time.LocalDateTime) ExecutionConfig(com.stardust.autojs.execution.ExecutionConfig) ViewGroup(android.view.ViewGroup) EActivity(org.androidannotations.annotations.EActivity) LocalDate(org.joda.time.LocalDate) List(java.util.List) TextView(android.widget.TextView) Toolbar(android.support.v7.widget.Toolbar) ExpandableRelativeLayout(com.github.aakira.expandablelayout.ExpandableRelativeLayout) TimePicker(android.widget.TimePicker) Nullable(android.support.annotation.Nullable) ViewById(org.androidannotations.annotations.ViewById) BaseActivity(com.stardust.scriptdroid.ui.BaseActivity) CheckedChange(org.androidannotations.annotations.CheckedChange) Click(org.androidannotations.annotations.Click) LocalTime(org.joda.time.LocalTime) TimePickerDialog(android.app.TimePickerDialog) Click(org.androidannotations.annotations.Click)

Example 29 with LocalTime

use of org.joda.time.LocalTime in project drill by axbaretto.

the class CompareFunctionsProcessor method visitSchemaPath.

@Override
public Boolean visitSchemaPath(SchemaPath path, LogicalExpression valueArg) throws RuntimeException {
    // If valueArg is null, this might be a IS NULL/IS NOT NULL type of query
    if (valueArg == null) {
        this.path = path;
        return true;
    }
    if (valueArg instanceof QuotedString) {
        this.value = KeyValueBuilder.initFrom(((QuotedString) valueArg).value);
        this.path = path;
        return true;
    }
    if (valueArg instanceof IntExpression) {
        this.value = KeyValueBuilder.initFrom(((IntExpression) valueArg).getInt());
        this.path = path;
        return true;
    }
    if (valueArg instanceof FloatExpression) {
        this.value = KeyValueBuilder.initFrom(((FloatExpression) valueArg).getFloat());
        this.path = path;
        return true;
    }
    if (valueArg instanceof BooleanExpression) {
        this.value = KeyValueBuilder.initFrom(((BooleanExpression) valueArg).getBoolean());
        this.path = path;
        return true;
    }
    if (valueArg instanceof Decimal28Expression) {
        this.value = KeyValueBuilder.initFrom(((Decimal28Expression) valueArg).getBigDecimal());
        this.path = path;
        return true;
    }
    if (valueArg instanceof Decimal38Expression) {
        this.value = KeyValueBuilder.initFrom(((Decimal38Expression) valueArg).getBigDecimal());
        this.path = path;
        return true;
    }
    if (valueArg instanceof DoubleExpression) {
        this.value = KeyValueBuilder.initFrom(((DoubleExpression) valueArg).getDouble());
        this.path = path;
        return true;
    }
    if (valueArg instanceof LongExpression) {
        this.value = KeyValueBuilder.initFrom(((LongExpression) valueArg).getLong());
        this.path = path;
        return true;
    }
    if (valueArg instanceof DateExpression) {
        long d = ((DateExpression) valueArg).getDate();
        final long MILLISECONDS_IN_A_DAY = (long) 1000 * 60 * 60 * 24;
        int daysSinceEpoch = (int) (d / MILLISECONDS_IN_A_DAY);
        this.value = KeyValueBuilder.initFrom(ODate.fromDaysSinceEpoch(daysSinceEpoch));
        this.path = path;
        return true;
    }
    if (valueArg instanceof TimeExpression) {
        int t = ((TimeExpression) valueArg).getTime();
        LocalTime lT = LocalTime.fromMillisOfDay(t);
        this.value = KeyValueBuilder.initFrom(new OTime(lT.getHourOfDay(), lT.getMinuteOfHour(), lT.getSecondOfMinute(), lT.getMillisOfSecond()));
        this.path = path;
        return true;
    }
    if (valueArg instanceof TimeStampExpression) {
    // disable pushdown of TimeStampExpression type until bug 22824 is fixed.
    // 
    // this.value = KeyValueBuilder.initFrom(new OTimestamp(((TimeStampExpression)valueArg).getTimeStamp()));
    // this.path = path;
    // return true;
    }
    return false;
}
Also used : LocalTime(org.joda.time.LocalTime) IntExpression(org.apache.drill.common.expression.ValueExpressions.IntExpression) Decimal38Expression(org.apache.drill.common.expression.ValueExpressions.Decimal38Expression) DoubleExpression(org.apache.drill.common.expression.ValueExpressions.DoubleExpression) FloatExpression(org.apache.drill.common.expression.ValueExpressions.FloatExpression) TimeExpression(org.apache.drill.common.expression.ValueExpressions.TimeExpression) TimeStampExpression(org.apache.drill.common.expression.ValueExpressions.TimeStampExpression) QuotedString(org.apache.drill.common.expression.ValueExpressions.QuotedString) BooleanExpression(org.apache.drill.common.expression.ValueExpressions.BooleanExpression) DateExpression(org.apache.drill.common.expression.ValueExpressions.DateExpression) Decimal28Expression(org.apache.drill.common.expression.ValueExpressions.Decimal28Expression) LongExpression(org.apache.drill.common.expression.ValueExpressions.LongExpression) OTime(org.ojai.types.OTime)

Example 30 with LocalTime

use of org.joda.time.LocalTime in project drill by apache.

the class TestDateFunctions method testToChar.

@Test
public void testToChar() throws Exception {
    mockUsDateFormatSymbols();
    String[] expectedResults = { (new LocalDate(2008, 2, 23)).toString("yyyy-MMM-dd"), (new LocalTime(12, 20, 30)).toString("HH mm ss"), (new LocalDateTime(2008, 2, 23, 12, 0, 0)).toString("yyyy MMM dd HH:mm:ss") };
    testCommon(expectedResults, "/functions/date/to_char.json", "/test_simple_date.json");
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) LocalTime(org.joda.time.LocalTime) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test) SqlFunctionTest(org.apache.drill.categories.SqlFunctionTest) UnlikelyTest(org.apache.drill.categories.UnlikelyTest)

Aggregations

LocalTime (org.joda.time.LocalTime)81 Test (org.junit.Test)39 OpeningHours (io.jawg.osmcontributor.model.utils.OpeningHours)17 LocalDate (org.joda.time.LocalDate)14 DateTime (org.joda.time.DateTime)13 LocalDateTime (org.joda.time.LocalDateTime)13 Date (java.util.Date)11 DateTimeZone (org.joda.time.DateTimeZone)10 OpeningMonth (io.jawg.osmcontributor.model.utils.OpeningMonth)6 Test (org.testng.annotations.Test)6 ArrayList (java.util.ArrayList)5 OpeningTime (io.jawg.osmcontributor.model.utils.OpeningTime)4 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)3 ContentValues (android.content.ContentValues)2 Time (java.sql.Time)2 EntityManager (javax.persistence.EntityManager)2 EntityTransaction (javax.persistence.EntityTransaction)2 JodaSample3 (org.datanucleus.samples.types.jodatime.JodaSample3)2 DatePickerDialog (android.app.DatePickerDialog)1 TimePickerDialog (android.app.TimePickerDialog)1