Search in sources :

Example 6 with LocalDate

use of org.threeten.bp.LocalDate in project material-calendarview by prolificinteractive.

the class MonthView method buildDayViews.

@Override
protected void buildDayViews(final Collection<DayView> dayViews, final LocalDate calendar) {
    LocalDate temp = calendar;
    for (int r = 0; r < DEFAULT_MAX_WEEKS; r++) {
        for (int i = 0; i < DEFAULT_DAYS_IN_WEEK; i++) {
            addDayView(dayViews, temp);
            temp = temp.plusDays(1);
        }
    }
}
Also used : LocalDate(org.threeten.bp.LocalDate) SuppressLint(android.annotation.SuppressLint)

Example 7 with LocalDate

use of org.threeten.bp.LocalDate in project material-calendarview by prolificinteractive.

the class BasicActivityDecorated method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_basic);
    ButterKnife.bind(this);
    widget.setOnDateChangedListener(this);
    widget.setShowOtherDates(MaterialCalendarView.SHOW_ALL);
    final LocalDate instance = LocalDate.now();
    widget.setSelectedDate(instance);
    final LocalDate min = LocalDate.of(instance.getYear(), Month.JANUARY, 1);
    final LocalDate max = LocalDate.of(instance.getYear(), Month.DECEMBER, 31);
    widget.state().edit().setMinimumDate(min).setMaximumDate(max).commit();
    widget.addDecorators(new MySelectorDecorator(this), new HighlightWeekendsDecorator(), oneDayDecorator);
    new ApiSimulator().executeOnExecutor(Executors.newSingleThreadExecutor());
}
Also used : HighlightWeekendsDecorator(com.prolificinteractive.materialcalendarview.sample.decorators.HighlightWeekendsDecorator) MySelectorDecorator(com.prolificinteractive.materialcalendarview.sample.decorators.MySelectorDecorator) LocalDate(org.threeten.bp.LocalDate)

Example 8 with LocalDate

use of org.threeten.bp.LocalDate in project SeriesGuide by UweTrottmann.

the class TimeToolsTest method test_applyUnitedStatesCorrections.

@Test
public void test_applyUnitedStatesCorrections() {
    // assume a US show releasing in Eastern time at 20:00
    LocalTime localTimeOf2000 = LocalTime.of(20, 0);
    ZoneId zoneIdUsEastern = ZoneId.of(TimeTools.TIMEZONE_ID_US_EASTERN);
    ZonedDateTime showDateTime = ZonedDateTime.of(LocalDate.of(2017, 1, 31), localTimeOf2000, zoneIdUsEastern);
    // Same local time as US Eastern
    applyAndAssertFor(showDateTime, localTimeOf2000, TimeTools.TIMEZONE_ID_US_EASTERN);
    applyAndAssertFor(showDateTime, localTimeOf2000, TimeTools.TIMEZONE_ID_US_EASTERN_DETROIT);
    applyAndAssertFor(showDateTime, localTimeOf2000, TimeTools.TIMEZONE_ID_US_PACIFIC);
    // One hour earlier local time than US Eastern
    LocalTime localTimeOf1900 = LocalTime.of(19, 0);
    applyAndAssertFor(showDateTime, localTimeOf1900, TimeTools.TIMEZONE_ID_US_CENTRAL);
    applyAndAssertFor(showDateTime, localTimeOf1900, TimeTools.TIMEZONE_ID_US_MOUNTAIN);
    // Same during winter...
    applyAndAssertFor(showDateTime, localTimeOf1900, TimeTools.TIMEZONE_ID_US_ARIZONA);
    // ...but observes no daylight saving
    LocalDate dateDuringDaylightSaving = LocalDate.of(2017, 5, 31);
    ZonedDateTime showTimeInDst = ZonedDateTime.of(dateDuringDaylightSaving, localTimeOf2000, zoneIdUsEastern);
    applyAndAssertFor(showTimeInDst, localTimeOf1900, TimeTools.TIMEZONE_ID_US_ARIZONA);
}
Also used : LocalTime(org.threeten.bp.LocalTime) ZoneId(org.threeten.bp.ZoneId) ZonedDateTime(org.threeten.bp.ZonedDateTime) LocalDate(org.threeten.bp.LocalDate) Test(org.junit.Test)

Example 9 with LocalDate

use of org.threeten.bp.LocalDate in project Eye by tommyolsson.

the class FragmentCreateEvent method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View inf = inflater.inflate(R.layout.fragment_create_event, container, false);
    // Changes title to the subject name
    ((MainActivity) getActivity()).setActionBarTitle(getResources().getString(R.string.newActivity));
    ((MainActivity) getActivity()).showBackButton();
    getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
    subjectEditText = (EditText) inf.findViewById(R.id.subjectEditText);
    locationEditText = (EditText) inf.findViewById(R.id.locationEditText);
    dateEditText = (EditText) inf.findViewById(R.id.dateEditText);
    startEditText = (EditText) inf.findViewById(R.id.startEditText);
    endEditText = (EditText) inf.findViewById(R.id.endEditText);
    dateEditText.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            // To show current date in the datepicker
            final Calendar mCalendar = Calendar.getInstance();
            int mYear = mCalendar.get(Calendar.YEAR);
            int mMonth = mCalendar.get(Calendar.MONTH);
            int mDay = mCalendar.get(Calendar.DAY_OF_MONTH);
            DatePickerDialog mDatePicker = new DatePickerDialog(getContext(), new DatePickerDialog.OnDateSetListener() {

                public void onDateSet(DatePicker datepicker, int selectedyear, int selectedmonth, int selectedday) {
                    // TODO Auto-generated method stub
                    /*  Set picked date in textedit  */
                    String myFormat = "yyyy-MM-dd";
                    SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.getDefault());
                    mCalendar.set(Calendar.YEAR, selectedyear);
                    mCalendar.set(Calendar.MONTH, selectedmonth);
                    mCalendar.set(Calendar.DAY_OF_MONTH, selectedday);
                    dateEditText.setText(sdf.format(mCalendar.getTime()));
                }
            }, mYear, mMonth, mDay);
            mDatePicker.getDatePicker().setCalendarViewShown(false);
            mDatePicker.setTitle("Select date");
            mDatePicker.show();
        }
    });
    startEditText.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Calendar mcurrentTime = Calendar.getInstance();
            int hour = mcurrentTime.get(Calendar.HOUR_OF_DAY);
            int minute = mcurrentTime.get(Calendar.MINUTE);
            TimePickerDialog mTimePicker;
            mTimePicker = new TimePickerDialog(getContext(), new TimePickerDialog.OnTimeSetListener() {

                @Override
                public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) {
                    startEditText.setText(String.format("%02d:%02d", selectedHour, selectedMinute));
                }
            }, hour, minute, // Yes 24 hour time
            true);
            mTimePicker.setTitle("Select Time");
            mTimePicker.show();
        }
    });
    endEditText.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Calendar mcurrentTime = Calendar.getInstance();
            int hour = mcurrentTime.get(Calendar.HOUR_OF_DAY);
            int minute = mcurrentTime.get(Calendar.MINUTE);
            TimePickerDialog mTimePicker;
            mTimePicker = new TimePickerDialog(getContext(), new TimePickerDialog.OnTimeSetListener() {

                @Override
                public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) {
                    endEditText.setText(String.format("%02d:%02d", selectedHour, selectedMinute));
                }
            }, hour, minute, // Yes 24 hour time
            true);
            mTimePicker.setTitle("Select Time");
            mTimePicker.show();
        }
    });
    checkBox = inf.findViewById(R.id.checkBox);
    checkBox.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (((CheckBox) v).isChecked()) {
                // Disables editText for time if event is all day
                startEditText.setEnabled(false);
                endEditText.setEnabled(false);
                isAllDay = true;
            } else {
                startEditText.setEnabled(true);
                endEditText.setEnabled(true);
                isAllDay = false;
            }
        }
    });
    createButton = inf.findViewById(R.id.createButton);
    createButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            String subject = subjectEditText.getText().toString();
            String location = locationEditText.getText().toString();
            String date = dateEditText.getText().toString();
            String start = startEditText.getText().toString();
            String end = endEditText.getText().toString();
            Log.i("Ämne", subject);
            Log.i("Plats", location);
            Log.i("Datum", date);
            Log.i("Start", start);
            Log.i("Slut", end);
            Log.i("Heldag", Boolean.toString(isAllDay));
            if (subject.matches("")) {
                Toast.makeText(getContext(), "Namn på aktivitet saknas", Toast.LENGTH_SHORT).show();
            } else {
                if (isAllDay) {
                    LocalDate ld = LocalDate.parse(date, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
                    String endDate = ld.plusDays(1).toString();
                    ((MainActivity) getActivity()).createEventGraphAPI(subject, location, date, endDate, "00", "00", isAllDay);
                } else {
                    ((MainActivity) getActivity()).createEventGraphAPI(subject, location, date, date, start, end, isAllDay);
                }
                Toast.makeText(getContext(), "Aktivitet skapad", Toast.LENGTH_SHORT).show();
                getActivity().onBackPressed();
            }
        }
    });
    return inf;
}
Also used : TimePicker(android.widget.TimePicker) DatePickerDialog(android.app.DatePickerDialog) Calendar(java.util.Calendar) TimePickerDialog(android.app.TimePickerDialog) MainActivity(kogvet.eye.MainActivity) View(android.view.View) LocalDate(org.threeten.bp.LocalDate) DatePicker(android.widget.DatePicker) SimpleDateFormat(java.text.SimpleDateFormat) Nullable(android.support.annotation.Nullable)

Example 10 with LocalDate

use of org.threeten.bp.LocalDate in project spring-data-commons by spring-projects.

the class ThreeTenBackPortConvertersUnitTests method convertsLocalDateToDate.

// DATACMNS-606
@Test
public void convertsLocalDateToDate() {
    LocalDate now = LocalDate.now();
    assertThat(format(CONVERSION_SERVICE.convert(now, Date.class), "yyyy-MM-dd")).isEqualTo(now.toString());
}
Also used : LocalDate(org.threeten.bp.LocalDate) Date(java.util.Date) LocalDate(org.threeten.bp.LocalDate) Test(org.junit.Test)

Aggregations

LocalDate (org.threeten.bp.LocalDate)20 SuppressLint (android.annotation.SuppressLint)4 ZonedDateTime (org.threeten.bp.ZonedDateTime)4 Nullable (android.support.annotation.Nullable)2 View (android.view.View)2 HighlightWeekendsDecorator (com.prolificinteractive.materialcalendarview.sample.decorators.HighlightWeekendsDecorator)2 MySelectorDecorator (com.prolificinteractive.materialcalendarview.sample.decorators.MySelectorDecorator)2 MainActivity (kogvet.eye.MainActivity)2 Test (org.junit.Test)2 TemporalField (org.threeten.bp.temporal.TemporalField)2 DatePickerDialog (android.app.DatePickerDialog)1 TimePickerDialog (android.app.TimePickerDialog)1 NonNull (android.support.annotation.NonNull)1 TabLayout (android.support.design.widget.TabLayout)1 DatePicker (android.widget.DatePicker)1 TimePicker (android.widget.TimePicker)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1