Search in sources :

Example 51 with LocalTime

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

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)

Example 52 with LocalTime

use of org.joda.time.LocalTime in project serenity-jbehave by serenity-bdd.

the class TimeListConverter method convertValue.

public Object convertValue(String value, Type type) {
    Type argumentType = argumentType(type);
    List<String> values = trim(asList(value.split(valueSeparator)));
    List<LocalTime> times = new ArrayList<>();
    for (String string : values) {
        times.add((LocalTime) timeConverter.convertValue(string, argumentType));
    }
    return times;
}
Also used : ParameterizedType(java.lang.reflect.ParameterizedType) Type(java.lang.reflect.Type) LocalTime(org.joda.time.LocalTime) ArrayList(java.util.ArrayList)

Example 53 with LocalTime

use of org.joda.time.LocalTime in project osm-contributor by jawg.

the class OpeningHoursValueParser method fromSingleValue.

public void fromSingleValue(String value, List<OpeningHours> openingHoursList) {
    // TODO: 19/07/16 We,Fr-Sa 10:45-19:15, Tu,Sa-Su 05:30-17:30, We 08:00-18:00
    OpeningHours openingHours = new OpeningHours();
    openingHours.setAllDaysActivated(false);
    String[] openingHoursValues = value.split(DAYS_SEP);
    String daysPart = null;
    String hoursPart = null;
    if (value.equals("24/7")) {
        daysPart = "Mo-Su";
        hoursPart = "24:00-24:00";
    } else if (openingHoursValues.length == 2) {
        daysPart = openingHoursValues[0];
        hoursPart = openingHoursValues[1];
    } else if (openingHoursValues.length == 1) {
        hoursPart = openingHoursValues[0];
    }
    if (daysPart != null) {
        String[] dayPeriods = daysPart.split(RULE_SEP);
        for (String period : dayPeriods) {
            if (isPeriod(period)) {
                OpeningHours.Days[] d = OpeningHours.Days.fromDatas(period.split(RANGE_SEP));
                for (int i = d[0].ordinal(); i <= d[1].ordinal(); i++) {
                    openingHours.setDayActivated(i, true);
                }
            } else {
                openingHours.setDayActivated(OpeningHours.Days.fromData(period).ordinal(), true);
            }
        }
    }
    if (hoursPart != null) {
        String[] hours = hoursPart.split(",");
        if (hours.length > 1) {
            for (String hour : hours) {
                value = daysPart + " " + hour;
                fromSingleValue(value, openingHoursList);
            }
        } else {
            String[] hourPeriod = hoursPart.split(RANGE_SEP);
            LocalTime from = TIME_FORMATTER.parseLocalTime(hourPeriod[0]);
            if (hourPeriod.length > 1) {
                LocalTime to = TIME_FORMATTER.parseLocalTime(hourPeriod[1]);
                openingHours.setToTime(to);
            } else {
                openingHours.setToTime(from.plusMinutes(5));
            }
            openingHours.setFromTime(from);
            openingHoursList.add(openingHours);
        }
    }
// return openingHours;
}
Also used : LocalTime(org.joda.time.LocalTime) OpeningHours(io.jawg.osmcontributor.model.utils.OpeningHours)

Example 54 with LocalTime

use of org.joda.time.LocalTime in project osm-contributor by jawg.

the class OpeningHoursValueParserTest method isNonStop1.

@Test
public void isNonStop1() {
    OpeningHours openingHours = new OpeningHours();
    openingHours.setFromTime(new LocalTime(0, 0));
    openingHours.setToTime(new LocalTime(0, 0));
    openingHours.setDays(OpeningHours.Days.values());
    Assert.assertTrue(parser.isNonStop(openingHours));
}
Also used : LocalTime(org.joda.time.LocalTime) OpeningHours(io.jawg.osmcontributor.model.utils.OpeningHours) Test(org.junit.Test)

Example 55 with LocalTime

use of org.joda.time.LocalTime in project osm-contributor by jawg.

the class OpeningHoursValueParserTest method isNonStop2.

@Test
public void isNonStop2() {
    OpeningHours openingHours = new OpeningHours();
    openingHours.setFromTime(new LocalTime(0, 0));
    openingHours.setToTime(new LocalTime(23, 50));
    openingHours.setDays(OpeningHours.Days.values());
    Assert.assertTrue(parser.isNonStop(openingHours));
}
Also used : LocalTime(org.joda.time.LocalTime) OpeningHours(io.jawg.osmcontributor.model.utils.OpeningHours) Test(org.junit.Test)

Aggregations

LocalTime (org.joda.time.LocalTime)83 Test (org.junit.Test)34 OpeningHours (io.jawg.osmcontributor.model.utils.OpeningHours)17 LocalDate (org.joda.time.LocalDate)16 DateTime (org.joda.time.DateTime)15 LocalDateTime (org.joda.time.LocalDateTime)15 Date (java.util.Date)12 DateTimeZone (org.joda.time.DateTimeZone)10 OpeningMonth (io.jawg.osmcontributor.model.utils.OpeningMonth)6 ProcessorTest (org.mapstruct.ap.testutil.ProcessorTest)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