Java 类org.joda.time.base.BaseLocal 实例源码

项目:jfixture    文件:BaseLocalRelay.java   
@Override
public Object create(Object request, SpecimenContext context) {

    if (!(request instanceof SpecimenType)) {
        return new NoSpecimen();
    }

    SpecimenType type = (SpecimenType) request;
    if (!BaseLocal.class.isAssignableFrom(type.getRawType())) {
        return new NoSpecimen();
    }

    Date date = (Date) context.resolve(Date.class);
    long instant = date.getTime();

    try {
        return type.getRawType().getDeclaredConstructor(long.class).newInstance(instant);
    } catch (Exception e) {
        e.printStackTrace();
        return new NoSpecimen();
    }
}
项目:SimpleDo    文件:QuickReschedule.java   
/**
 * Creates a date object using the user selected date and time from the date and time pickers.
 * Null if no date selected.
 *
 * @return a date object with user selected date/time or null if no date selected
 */
private BaseLocal createDate() {
    if (dateToggleButton.isChecked()) {
        if (timeToggleButton.isChecked()) {
            return new LocalDateTime(datePicker.getYear(), datePicker.getMonth() + 1, datePicker.getDayOfMonth(), timePicker.getCurrentHour(), timePicker.getCurrentMinute(), 0);
        } else {
            return new LocalDate(datePicker.getYear(), datePicker.getMonth() + 1, datePicker.getDayOfMonth());
        }
    } else return null;
}
项目:SimpleDo    文件:ToDoItem.java   
/**
 * Constructs an instance.
 *
 * @param name     The name
 * @param date     The due date (Null if no due date set)
 * @param group    The group (No Group, Work, Personal)
 * @param priority The priority (Not Set, Low, Medium, High)
 * @param timeSet
 */
public ToDoItem(String name, BaseLocal date, String group, String priority, boolean timeSet) {
    this.name = name;
    this.date = date;
    this.group = group;
    this.priority = priority;
    this.timeSet = timeSet;
    complete = false;

    if (!(this.group.equals("No Group") || this.group.equals("Work") || this.group.equals("Personal") || this.group.equals("School")))
        throw new IllegalArgumentException("No such group exists.");
    if (!(this.priority.equals("Not Set") || this.priority.equals("Low") || this.priority.equals("Medium") || this.priority.equals("High")))
        throw new IllegalArgumentException("No such priority exists.");
}
项目:SimpleDo    文件:EditItem.java   
/**
 * Creates a date object using the user selected date and time from the date and time pickers.
 * Null if no date selected.
 *
 * @return a date object with user selected date/time
 */
private BaseLocal createDate() {
    if (dateToggleButton.isChecked()) {
        if (timeToggleButton.isChecked()) {
            return new LocalDateTime(datePicker.getYear(), datePicker.getMonth() + 1, datePicker.getDayOfMonth(), timePicker.getCurrentHour(), timePicker.getCurrentMinute(), 0);
        } else {
            return new LocalDate(datePicker.getYear(), datePicker.getMonth() + 1, datePicker.getDayOfMonth());
        }

    } else return null;
}
项目:SimpleDo    文件:CreateItem.java   
/**
 * Creates a date object using the user selected date and time from the date and time pickers.
 * Null if no date selected.
 *
 * @return a date object with user selected date/time
 */
private BaseLocal createDate() {
    if (dateToggleButton.isChecked()) {
        if (timeToggleButton.isChecked()) {
            return new LocalDateTime(datePicker.getYear(), datePicker.getMonth() + 1, datePicker.getDayOfMonth(), timePicker.getCurrentHour(), timePicker.getCurrentMinute(), 0);
        } else {
            return new LocalDate(datePicker.getYear(), datePicker.getMonth() + 1, datePicker.getDayOfMonth());
        }
    } else return null;
}
项目:beanmother    文件:StringToJodaTimeBaseLocalConverter.java   
@Override
public boolean canHandle(Object source, TypeToken<?> targetTypeToken) {
    return targetTypeToken.isSubtypeOf(BaseLocal.class) && stringToDateConverter.canHandle(source, TypeToken.of(Date.class));
}
项目:beanmother    文件:DateToJodaTimeBaseLocalConverter.java   
@Override
public boolean canHandle(Object source, TypeToken<?> targetTypeToken) {
    return targetTypeToken.isSubtypeOf(BaseLocal.class) && (source instanceof Date);
}
项目:SimpleDo    文件:ItemsDataSource.java   
/**
 * Converts data from the database into ToDoItem objects.
 *
 * @param cursor To be converted into a ToDoItem
 * @return ToDoItem with values from the cursor
 */
private ToDoItem cursorToItem(Cursor cursor) {
    long id = cursor.getLong(0);
    String name = cursor.getString(1);

    BaseLocal date;

    if (cursor.getString(2).equals("null")) {
        date = null;
    } else {
        String split[] = cursor.getString(2).split(":");
        if (split[split.length - 1].equals("00")) {
            date = formatter.parseLocalDateTime(cursor.getString(2));
        } else {
            split = cursor.getString(2).split(" ");
            //need better solution
            split = split[0].split("/");

            StringBuilder stringBuilder = new StringBuilder();
            for (int i = split.length - 1; i > -1; i--) {
                stringBuilder.append(split[i]);
                if (i != 0) {
                    stringBuilder.append("-");
                }
            }

            String parseDate = stringBuilder.toString();

            date = new LocalDate(parseDate);
        }
    }

    boolean complete;
    if (cursor.getString(3).equals("0")) complete = false;
    else complete = true;

    String group = cursor.getString(4);
    String priority = cursor.getString(5);
    boolean reminder = Boolean.parseBoolean(cursor.getString(6));
    long eventID = cursor.getLong(7);
    boolean timeSet = Boolean.parseBoolean(cursor.getString(8));

    ToDoItem toDoItem = new ToDoItem(name, date, group, priority, timeSet);
    toDoItem.setId(id);
    toDoItem.setEventID(eventID);
    toDoItem.setComplete(complete);
    toDoItem.setReminder(reminder);
    return toDoItem;
}
项目:SimpleDo    文件:ToDoItem.java   
/**
 * Returns null if no date has been set.
 *
 * @return date
 */
public BaseLocal getDate() {
    return date;
}