Example usage for org.joda.time LocalDate LocalDate

List of usage examples for org.joda.time LocalDate LocalDate

Introduction

In this page you can find the example usage for org.joda.time LocalDate LocalDate.

Prototype

public LocalDate() 

Source Link

Document

Constructs an instance set to the current local time evaluated using ISO chronology in the default zone.

Usage

From source file:com.fourmob.datetimepicker.date.DatePicker.java

License:Open Source License

public DatePicker(final Context context, final AttributeSet attrs) {
    super(context, attrs);
    final TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.DatePicker, 0, 0);
    this.mCalendar = new LocalDate();
    try {//from   w ww .j  a va  2 s  . c o m
        mCalendar = mCalendar.withYear(a.getInt(R.styleable.DatePicker_initialYear, this.mCalendar.getYear()));
        mCalendar = mCalendar.withMonthOfYear(
                a.getInt(R.styleable.DatePicker_initialMonth, this.mCalendar.getMonthOfYear()));
        mCalendar = mCalendar
                .withDayOfMonth(a.getInt(R.styleable.DatePicker_initialDay, this.mCalendar.getDayOfMonth()));
        this.mMaxYear = a.getInt(R.styleable.DatePicker_maxYear, MAX_YEAR);
        this.mMinYear = a.getInt(R.styleable.DatePicker_minYear, MIN_YEAR);
    } finally {
        a.recycle();
    }
    setupView(context);
}

From source file:com.fourmob.datetimepicker.date.SimpleMonthView.java

License:Open Source License

public SimpleMonthView(final Context context) {
    super(context);
    this.mDayLabelCalendar = new LocalDate();
    this.mCalendar = mDayLabelCalendar;
    this.mDayOfWeekTypeface = getResources().getString(R.string.day_of_week_label_typeface);
    this.mMonthTitleTypeface = getResources().getString(R.string.sans_serif);
    this.mDayTextColor = ThemeManager.getColor(R.attr.colorTextBlack);
    this.mTodayNumberColor = ThemeManager.getPrimaryThemeColor();
    this.mMonthTitleColor = ThemeManager.getColor(R.attr.colorTextGrey);
    this.mMonthTitleBGColor = ThemeManager.getColor(R.attr.colorBackground);
    this.mStringBuilder = new StringBuilder(50);
    MINI_DAY_NUMBER_TEXT_SIZE = getResources().getDimensionPixelSize(R.dimen.day_number_size);
    MONTH_LABEL_TEXT_SIZE = getResources().getDimensionPixelSize(R.dimen.month_label_size);
    MONTH_DAY_LABEL_TEXT_SIZE = getResources().getDimensionPixelSize(R.dimen.month_day_label_text_size);
    MONTH_HEADER_SIZE = getResources().getDimensionPixelOffset(R.dimen.month_list_item_header_height);
    DAY_SELECTED_CIRCLE_SIZE = getResources().getDimensionPixelSize(R.dimen.day_number_select_circle_radius);
    this.mRowHeight = (getResources().getDimensionPixelOffset(R.dimen.date_picker_view_animator_height)
            - MONTH_HEADER_SIZE) / 6;//  ww  w.j a v a 2s  . com
    this.mBackground = ThemeManager.getColor(R.attr.colorBackground);
    initView();
}

From source file:com.fourmob.datetimepicker.date.SimpleMonthView.java

License:Open Source License

public void setMonthParams(final HashMap<String, Integer> monthParams) {
    if (!monthParams.containsKey("month") && !monthParams.containsKey("year")) {
        throw new InvalidParameterException("You must specify the month and year for this view");
    }/*from  ww  w. ja  v  a  2 s  . c om*/
    setTag(monthParams);
    if (monthParams.containsKey("height")) {
        this.mRowHeight = monthParams.get("height").intValue();
        if (this.mRowHeight < MIN_HEIGHT) {
            this.mRowHeight = MIN_HEIGHT;
        }
    }
    if (monthParams.containsKey("selected_day")) {
        this.mSelectedDay = monthParams.get("selected_day").intValue();
    }
    this.mMonth = monthParams.get("month").intValue();
    this.mYear = monthParams.get("year").intValue();
    this.mHasToday = false;
    this.mToday = -1;
    mCalendar = mCalendar.withYear(mYear).withMonthOfYear(mMonth).withDayOfMonth(1);
    this.mDayOfWeekStart = this.mCalendar.getDayOfWeek();
    this.mWeekStart = ((Calendar.getInstance(Helpers.getLocale(getContext())).getFirstDayOfWeek() + 5)
            % SimpleMonthView.mNumDays) + 1;
    this.mNumCells = Utils.getDaysInMonth(this.mMonth, this.mYear);
    final LocalDate now = new LocalDate();
    if (mMonth == now.getMonthOfYear()) {
        for (int day = 0; day < this.mNumCells; day++) {
            if (now.getDayOfMonth() == day + 1) {
                this.mHasToday = true;
                this.mToday = now.getDayOfMonth();
            }
        }
    }
    this.mNumRows = calculateNumRows();
}

From source file:com.fourmob.datetimepicker.date.SupportDatePickerDialog.java

License:Open Source License

public static SupportDatePickerDialog newInstance(final OnDateSetListener onDateSetListener,
        final @NonNull Optional<DateTime> mStartDate) {
    if (mStartDate.isPresent()) {
        return newInstance(onDateSetListener, mStartDate.get().toLocalDate());
    } else {/*  w  w w  .j  a  v  a  2s  .  c  o m*/
        return newInstance(onDateSetListener, new LocalDate());
    }
}

From source file:com.google.api.ads.adwords.awreporting.model.util.DateUtil.java

License:Open Source License

/**
 * Create a {@code LocalDate} that represents the last month, and formats it to the yyyy-MM 
 * format.//from w w w.  jav  a  2  s  .c o  m
 *
 * @return the date formatted
 */
public static String lastMonthInYearMonthFormat() {
    LocalDate lastMonth = new LocalDate().minusMonths(1);
    return DATE_FORMATTER_YEAR_MONTH.print(lastMonth);
}

From source file:com.google.api.ads.adwords.awreporting.model.util.DateUtil.java

License:Open Source License

/**
 * Get a LocalDate for the first day of the previous month.
 * @return LocalDate//  w w  w . j  av  a 2  s  . co  m
 */
public static LocalDate firstDayPreviousMonth() {
    return new LocalDate().minusMonths(1).dayOfMonth().withMinimumValue();
}

From source file:com.google.api.ads.adwords.awreporting.model.util.DateUtil.java

License:Open Source License

/**
 * Get a LocalDate for the last day of the previous month.
 * @return LocalDate/*w ww . ja va 2  s .co m*/
 */
public static LocalDate lastDayPreviousMonth() {
    return new LocalDate().minusMonths(1).dayOfMonth().withMaximumValue();
}

From source file:com.gs.fw.common.mithra.attribute.calculator.arithmeticCalculator.DateYearCalculator.java

License:Apache License

@Override
public Operation optimizedIntegerEq(int value, CalculatedIntegerAttribute intAttribute) {
    LocalDate localDateBefore = new LocalDate().withYear(value).withDayOfMonth(1).withMonthOfYear(1);
    LocalDate localDateAfter = new LocalDate().withYear(value + 1).withDayOfMonth(1).withMonthOfYear(1);

    return this.attribute.greaterThanEquals(localDateBefore.toDate())
            .and(attribute.lessThan(localDateAfter.toDate()));
}

From source file:com.gst.infrastructure.campaigns.sms.domain.SmsCampaign.java

License:Apache License

public static SmsCampaign instance(final AppUser submittedBy, final Report report, final JsonCommand command) {

    final String campaignName = command.stringValueOfParameterNamed(SmsCampaignValidator.campaignName);
    final Long campaignType = command.longValueOfParameterNamed(SmsCampaignValidator.campaignType);
    final Long triggerType = command.longValueOfParameterNamed(SmsCampaignValidator.triggerType);
    final Long providerId = command.longValueOfParameterNamed(SmsCampaignValidator.providerId);
    final String paramValue = command.jsonFragment(SmsCampaignValidator.paramValue);

    final String message = command.stringValueOfParameterNamed(SmsCampaignValidator.message);
    LocalDate submittedOnDate = new LocalDate();
    if (command.hasParameter(SmsCampaignValidator.submittedOnDateParamName)) {
        submittedOnDate = command.localDateValueOfParameterNamed(SmsCampaignValidator.submittedOnDateParamName);
    }//from w  w  w  . j  a v  a2s.  c om
    String recurrence = null;

    LocalDateTime recurrenceStartDate = new LocalDateTime();
    if (SmsCampaignTriggerType.fromInt(triggerType.intValue()).isSchedule()) {
        final Locale locale = command.extractLocale();
        String dateTimeFormat = null;
        if (command.hasParameter(SmsCampaignValidator.dateTimeFormat)) {
            dateTimeFormat = command.stringValueOfParameterNamed(SmsCampaignValidator.dateTimeFormat);
            final DateTimeFormatter fmt = DateTimeFormat.forPattern(dateTimeFormat).withLocale(locale);
            if (command.hasParameter(SmsCampaignValidator.recurrenceStartDate)) {
                recurrenceStartDate = LocalDateTime.parse(
                        command.stringValueOfParameterNamed(SmsCampaignValidator.recurrenceStartDate), fmt);
            }
            recurrence = constructRecurrence(command);
        }
    } else {
        recurrenceStartDate = null;
    }

    return new SmsCampaign(campaignName, campaignType.intValue(), triggerType.intValue(), report, providerId,
            paramValue, message, submittedOnDate, submittedBy, recurrence, recurrenceStartDate);
}

From source file:com.gst.infrastructure.core.serialization.JsonParserHelper.java

License:Apache License

/**
 * Used with the local date is in array format
 *///from   w  ww. j a va 2  s .c  om
public LocalDate extractLocalDateAsArrayNamed(final String parameterName, final JsonElement element,
        final Set<String> parametersPassedInCommand) {
    LocalDate value = null;
    if (element.isJsonObject()) {
        final JsonObject object = element.getAsJsonObject();

        if (object.has(parameterName) && object.get(parameterName).isJsonArray()) {

            parametersPassedInCommand.add(parameterName);

            final JsonArray dateArray = object.get(parameterName).getAsJsonArray();

            final Integer year = dateArray.get(0).getAsInt();
            final Integer month = dateArray.get(1).getAsInt();
            final Integer day = dateArray.get(2).getAsInt();

            value = new LocalDate().withYearOfEra(year).withMonthOfYear(month).withDayOfMonth(day);
        }

    }
    return value;
}