Java 类org.joda.time.LocalDate 实例源码
项目:autorest.java
文件:PathsImpl.java
/**
* Get '2012-01-01' as date.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceResponse} object if successful.
*/
public Observable<ServiceResponse<Void>> dateValidWithServiceResponseAsync() {
final LocalDate datePath = LocalDate.parse("2012-01-01");
return service.dateValid(datePath)
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Void>>>() {
@Override
public Observable<ServiceResponse<Void>> call(Response<ResponseBody> response) {
try {
ServiceResponse<Void> clientResponse = dateValidDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
项目:CalendarPicker
文件:MyConfig.java
public static CalendarWeek getWeekIncludeThisDay(LocalDate localDate) {
LocalDate monday = localDate.withDayOfWeek(DateTimeConstants.MONDAY);
LocalDate tuesday = localDate.withDayOfWeek(DateTimeConstants.TUESDAY);
LocalDate wednesday = localDate.withDayOfWeek(DateTimeConstants.WEDNESDAY);
LocalDate thursday = localDate.withDayOfWeek(DateTimeConstants.THURSDAY);
LocalDate friday = localDate.withDayOfWeek(DateTimeConstants.FRIDAY);
LocalDate saturday = localDate.withDayOfWeek(DateTimeConstants.SATURDAY);
LocalDate sunday = localDate.withDayOfWeek(DateTimeConstants.SUNDAY);
CalendarWeek calendarWeek = new CalendarWeek(
monday,
tuesday,
wednesday,
thursday,
friday,
saturday,
sunday
);
calendarWeek.firstDayOfCurrentMonth = localDate.withDayOfMonth(1);
calendarWeek.originDate = localDate;
return calendarWeek;
}
项目:CalendarPicker
文件:MyConfig.java
public static CalendarMonth getMonthIncludeThisDay(LocalDate localDate) {
CalendarMonth calendarMonth = new CalendarMonth();
calendarMonth.firstDayOfCurrentMonth = localDate.withDayOfMonth(1);
for (int i = 0; i < 6; i++) {//每个月最多6周,最少4周
CalendarWeek w = getWeekIncludeThisDay(calendarMonth.firstDayOfCurrentMonth.plusDays(7 * i));
if (i < 4) {
calendarMonth.calendarWeeks.addLast(w);
} else if (w.calendarDayList.getFirst().day.getMonthOfYear() == calendarMonth.firstDayOfCurrentMonth.getMonthOfYear()) {
/**
* 从第5周开始检
* 如果w的第一天的月份等于本月第一天的月份,那么这一周也算本月的周
*/
calendarMonth.calendarWeeks.addLast(w);
} else {
break;
}
}
calendarMonth.originDate = localDate;
return calendarMonth;
}
项目:mod-circulation-storage
文件:RequestRequestBuilder.java
private RequestRequestBuilder(
UUID id,
String requestType,
DateTime requestDate,
UUID itemId,
UUID requesterId,
String fulfilmentPreference,
UUID deliveryAddressTypeId,
LocalDate requestExpirationDate,
LocalDate holdShelfExpirationDate,
ItemSummary itemSummary,
PatronSummary requesterSummary) {
this.id = id;
this.requestType = requestType;
this.requestDate = requestDate;
this.itemId = itemId;
this.requesterId = requesterId;
this.fulfilmentPreference = fulfilmentPreference;
this.deliveryAddressTypeId = deliveryAddressTypeId;
this.requestExpirationDate = requestExpirationDate;
this.holdShelfExpirationDate = holdShelfExpirationDate;
this.itemSummary = itemSummary;
this.requesterSummary = requesterSummary;
}
项目:mbed-cloud-sdk-java
文件:ApiClient.java
public void createDefaultAdapter() {
Gson gson = new GsonBuilder()
.setDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
.registerTypeAdapter(DateTime.class, new DateTimeTypeAdapter())
.registerTypeAdapter(LocalDate.class, new LocalDateTypeAdapter())
.create();
okBuilder = new OkHttpClient.Builder();
String baseUrl = "https://api.us-east-1.mbedcloud.com";
if(!baseUrl.endsWith("/"))
baseUrl = baseUrl + "/";
adapterBuilder = new Retrofit
.Builder()
.baseUrl(baseUrl)
.addConverterFactory(ScalarsConverterFactory.create())
.addConverterFactory(GsonCustomConverterFactory.create(gson));
}
项目:yum
文件:DailyMenuService.java
/**
* @return a list to the chef, of Daily Menus of month & year he wants
*/
@PreAuthorize("hasAuthority('chef')")
public List<DailyMenuChef> dailyMenusMonthlyMonthyearGet(String monthyear) throws ApiException
{
String patternString = "^\\d{2}-\\d{4}$";
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile(patternString);
Matcher matcher = pattern.matcher(monthyear);
if (matcher.matches())
{
LocalDate monthYearDate = new LocalDate().withYear(Integer.parseInt(monthyear.substring(3, 7))).withMonthOfYear(Integer.parseInt(monthyear.substring(0, 2)));
LocalDate startOfMonth = monthYearDate.dayOfMonth().withMinimumValue();
int daysOfMonth = monthYearDate.dayOfMonth().withMaximumValue().getDayOfMonth();
List<DailyMenuChef> monthlyMenu = new ArrayList<>();
for (int i = 0; i < daysOfMonth; i++)
{
if (getDailyMenuChef(startOfMonth).getDate() != null)
monthlyMenu.add(getDailyMenuChef(startOfMonth));
startOfMonth = startOfMonth.plusDays(1);
}
return monthlyMenu;
}
else
throw new ApiException(400, "Invalid date");
}
项目:morf
文件:RecordHelper.java
/**
* Take a string value retrieved from a {@link Record} and convert it to a java value of the specified
* type.
*
* @param stringValue The value retrieved from a {@link Record}.
* @param type The Java class to use for the result.
* @param <T> The Java type corresponding to the supplied Class
* @return The typed java value.
*/
@SuppressWarnings("unchecked")
public static <T> T recordValueToJavaType(String stringValue, Class<T> type) {
if (type == Integer.class) {
return (T)Integer.valueOf(stringValue);
} else if (type == Long.class) {
return (T)Long.valueOf(stringValue);
} else if (type == Boolean.class) {
return (T)Boolean.valueOf(stringValue);
} else if (type == LocalDate.class) {
return (T)LocalDate.parse(stringValue, FROM_YYYY_MM_DD);
} else if (type == Double.class) {
return (T)Double.valueOf(stringValue);
} else {
return (T)stringValue;
}
}
项目:exam
文件:ReservationAPIController.java
@SubjectNotPresent
public Result getRoomOpeningHours(Long roomId, Optional<String> date) {
if (!date.isPresent()) {
return badRequest("no search date given");
}
LocalDate searchDate = ISODateTimeFormat.dateParser().parseLocalDate(date.get());
PathProperties pp = PathProperties.parse("(*, defaultWorkingHours(*), calendarExceptionEvents(*))");
Query<ExamRoom> query = Ebean.find(ExamRoom.class);
pp.apply(query);
ExamRoom room = query.where().idEq(roomId).findUnique();
if (room == null) {
return notFound("room not found");
}
room.setCalendarExceptionEvents(room.getCalendarExceptionEvents().stream().filter(ee -> {
LocalDate start = new LocalDate(ee.getStartDate()).withDayOfMonth(1);
LocalDate end = new LocalDate(ee.getEndDate()).dayOfMonth().withMaximumValue();
return !start.isAfter(searchDate) && !end.isBefore(searchDate);
}).collect(Collectors.toList()));
return ok(room, pp);
}
项目:autorest.java
文件:PathsImpl.java
/**
* Get null as date - this should throw or be unusable on the client side, depending on date representation.
*
* @param datePath null as date (should throw)
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceResponse} object if successful.
*/
public Observable<ServiceResponse<Void>> dateNullWithServiceResponseAsync(LocalDate datePath) {
if (datePath == null) {
throw new IllegalArgumentException("Parameter datePath is required and cannot be null.");
}
return service.dateNull(datePath)
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Void>>>() {
@Override
public Observable<ServiceResponse<Void>> call(Response<ResponseBody> response) {
try {
ServiceResponse<Void> clientResponse = dateNullDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
项目:moneytracking
文件:DBHelper.java
public double getTotalExpense(LocalDate start, LocalDate end) {
List<MoneyItem> l = daoSession.getMoneyItemDao().queryBuilder().where(MoneyItemDao.Properties.Amount.lt(0)).where(MoneyItemDao.Properties.Date.between(start.toDate(), end.toDate())).list();
double total = 0.0;
ListIterator<MoneyItem> listIterator = l.listIterator();
while (listIterator.hasNext()) {
total += listIterator.next().getAmount();
}
return total;
}
项目:exam
文件:CalendarController.java
@Restrict({@Group("ADMIN"), @Group("STUDENT")})
public Result getSlots(Long examId, Long roomId, String day, Collection<Integer> aids) {
User user = getLoggedUser();
Exam exam = getEnrolledExam(examId, user);
if (exam == null) {
return forbidden("sitnet_error_enrolment_not_found");
}
ExamRoom room = Ebean.find(ExamRoom.class, roomId);
if (room == null) {
return forbidden(String.format("No room with id: (%d)", roomId));
}
Collection<TimeSlot> slots = new ArrayList<>();
if (!room.getOutOfService() && !room.getState().equals(ExamRoom.State.INACTIVE.toString()) &&
isRoomAccessibilitySatisfied(room, aids) && exam.getDuration() != null) {
LocalDate searchDate;
try {
searchDate = parseSearchDate(day, exam, room);
} catch (NotFoundException e) {
return notFound();
}
// users reservations starting from now
List<Reservation> reservations = Ebean.find(Reservation.class)
.fetch("enrolment.exam")
.where()
.eq("user", user)
.gt("startAt", searchDate.toDate())
.findList();
// Resolve eligible machines based on software and accessibility requirements
List<ExamMachine> machines = getEligibleMachines(room, aids, exam);
LocalDate endOfSearch = getEndSearchDate(exam, searchDate);
while (!searchDate.isAfter(endOfSearch)) {
Set<TimeSlot> timeSlots = getExamSlots(user, room, exam, searchDate, reservations, machines);
if (!timeSlots.isEmpty()) {
slots.addAll(timeSlots);
}
searchDate = searchDate.plusDays(1);
}
}
return ok(Json.toJson(slots));
}
项目:coner-core-client-java
文件:JSON.java
@Override
public LocalDate read(JsonReader in) throws IOException {
switch (in.peek()) {
case NULL:
in.nextNull();
return null;
default:
String date = in.nextString();
return formatter.parseLocalDate(date);
}
}
项目:killbill-easytax-plugin
文件:EasyTaxTestUtils.java
public static Invoice createInvoice(DateTime createdDate, LocalDate invoiceDate,
List<InvoiceItem> invoiceItems) {
UUID id = UUID.randomUUID();
Invoice invoice = Mockito.mock(Invoice.class,
Mockito.withSettings().defaultAnswer(RETURNS_SMART_NULLS.get()));
when(invoice.getId()).thenReturn(id);
when(invoice.getCreatedDate()).thenReturn(createdDate);
when(invoice.getInvoiceDate()).thenReturn(invoiceDate);
when(invoice.getInvoiceItems()).thenReturn(invoiceItems);
return invoice;
}
项目:morf
文件:AbstractSqlDialectTest.java
/**
* Tests SQL date conversion to string via databaseSafeStringtoRecordValue
*
* @throws SQLException If a SQL exception is thrown.
*/
@Test
public void testSqlDateConversion() throws SQLException {
ResultSet rs = mock(ResultSet.class);
LocalDate localDate1 = new LocalDate(2010, 1, 1);
LocalDate localDate2 = new LocalDate(2010, 12, 21);
LocalDate localDate3 = new LocalDate(100, 1, 1);
LocalDate localDate4 = new LocalDate(9999, 12, 31);
java.sql.Date date1 = new java.sql.Date(localDate1.toDate().getTime());
java.sql.Date date2 = new java.sql.Date(localDate2.toDate().getTime());
java.sql.Date date3 = new java.sql.Date(localDate3.toDate().getTime());
java.sql.Date date4 = new java.sql.Date(localDate4.toDate().getTime());
when(rs.getDate(1)).thenReturn(date1);
when(rs.getDate(2)).thenReturn(date2);
when(rs.getDate(3)).thenReturn(date3);
when(rs.getDate(4)).thenReturn(date4);
Record record = testDialect.resultSetToRecord(rs, ImmutableList.of(
column("Date1", DataType.DATE),
column("Date2", DataType.DATE),
column("Date3", DataType.DATE),
column("Date4", DataType.DATE)
));
assertEquals(localDate1, record.getLocalDate("Date1"));
assertEquals(localDate2, record.getLocalDate("Date2"));
assertEquals(localDate3, record.getLocalDate("Date3"));
assertEquals(localDate4, record.getLocalDate("Date4"));
assertEquals(date1, record.getDate("Date1"));
assertEquals(date2, record.getDate("Date2"));
assertEquals(date3, record.getDate("Date3"));
assertEquals(date4, record.getDate("Date4"));
}
项目:afp-api-client
文件:JSON.java
@Override
public LocalDate read(JsonReader in) throws IOException {
switch (in.peek()) {
case NULL:
in.nextNull();
return null;
default:
String date = in.nextString();
return formatter.parseLocalDate(date);
}
}
项目:autorest.java
文件:PrimitiveTests.java
@Test
public void putDate() throws Exception {
DateWrapper body = new DateWrapper();
body.withField(new LocalDate(1, 1, 1));
body.withLeap(new LocalDate(2016, 2, 29));
client.primitives().putDate(body);
}
项目:nifi-swagger-client
文件:JSON.java
@Override
public void write(JsonWriter out, LocalDate date) throws IOException {
if (date == null) {
out.nullValue();
} else {
out.value(formatter.print(date));
}
}
项目:PI-Web-API-Client-Java-Android
文件:JSON.java
/**
* JSON constructor.
*
* @param apiClient An instance of ApiClient
*/
public JSON(ApiClient apiClient) {
this.apiClient = apiClient;
gson = new GsonBuilder()
.registerTypeAdapter(Date.class, new DateAdapter(apiClient))
.registerTypeAdapter(DateTime.class, new DateTimeTypeAdapter())
.registerTypeAdapter(LocalDate.class, new LocalDateTypeAdapter())
.create();
}
项目:verify-hub
文件:CertificateHealthCheckDto.java
public static CertificateHealthCheckDto createCertificateHealthCheckDto(
String entityId,
Certificate certificate,
Duration warningPeriod) throws CertificateException {
CertificateExpiryStatus status = certificate.getExpiryStatus(warningPeriod);
String expiryDate = new LocalDate(certificate.getNotAfter()).toString(EXPIRY_DATE_FORMAT);
String message = getExpiryStatusMessage(status, expiryDate);
return new CertificateHealthCheckDto(entityId, certificate.getType(), status, message);
}
项目:verify-matching-service-adapter
文件:UserAccountCreationAttributeFactory.java
private AttributeValue createAttributeValuesForDate(SimpleMdsValue<LocalDate> dateValue) {
final Date dateOfBirthAttributeValue = openSamlXmlObjectFactory.createDateAttributeValue(dateValue.getValue().toString("yyyy-MM-dd"));
dateOfBirthAttributeValue.setFrom(dateValue.getFrom());
dateOfBirthAttributeValue.setTo(dateValue.getTo());
dateOfBirthAttributeValue.setVerified(dateValue.isVerified());
return dateOfBirthAttributeValue;
}
项目:autorest.java
文件:DatesImpl.java
/**
* Put min date value 0000-01-01.
*
* @param dateBody the LocalDate value
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceResponse} object if successful.
*/
public Observable<Void> putMinDateAsync(LocalDate dateBody) {
return putMinDateWithServiceResponseAsync(dateBody).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
}
项目:autorest.java
文件:DictionarysImpl.java
/**
* Get integer dictionary value {"0": "2000-12-01", "1": "1980-01-02", "2": "1492-10-12"}.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the Map<String, LocalDate> object
*/
public Observable<ServiceResponse<Map<String, LocalDate>>> getDateValidWithServiceResponseAsync() {
return service.getDateValid()
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Map<String, LocalDate>>>>() {
@Override
public Observable<ServiceResponse<Map<String, LocalDate>>> call(Response<ResponseBody> response) {
try {
ServiceResponse<Map<String, LocalDate>> clientResponse = getDateValidDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
项目:morf
文件:TestDataValueLookupTemporaryDefaultMethods.java
@Test
public void testGetLocalDate() {
DataValueLookup dataValueLookup = newDataValueLookup("2010-07-02");
assertThat(dataValueLookup.getLocalDate("B"), nullValue());
assertThat(dataValueLookup.getLocalDate(FIELD), equalTo(new LocalDate(2010, 7, 2)));
assertThat(dataValueLookup.getLocalDate(FIELD.toUpperCase()), equalTo(new LocalDate(2010, 7, 2)));
assertEquals(dataValueLookup.getObject(column(FIELD, DataType.DATE)), java.sql.Date.valueOf("2010-07-02"));
assertEquals(dataValueLookup.getObject(column(FIELD, DataType.STRING)), "2010-07-02");
}
项目:yum
文件:UsersService.java
public boolean deadlinePassed(LocalDate date) {
Settings settings = settingsRepo.findOne(1);
int deadlineDays = settings.getDeadlineDays();
LocalTime deadlineTime = settings.getDeadline();
date = date.minusDays(deadlineDays);
while (this.holidaysRepo.findByIdHoliday(date) != null) {
date = date.minusDays(1);
}
// Check if order deadline passed based on given date, deadlineDays and deadlineTime (deadline)
return (date.toLocalDateTime(deadlineTime).compareTo(LocalDateTime.now()) < 0);
}
项目:yum
文件:ReportEmail.java
private void sendAutoOrderSummary(){
System.out.println("RUN TASK SCHEDULE: " + LocalDateTime.now());
//Get deadline days
Settings settings = settingsRepo.findById(1);
int deadlinedays = settings.getDeadlineDays();
LocalDate day = new LocalDate();
if(this.holidaysRepo.findByIdHoliday(day) != null){
return;
}
LocalDate initDate = (day).plusDays(deadlinedays);
// while (this.holidaysRepo.findByIdHoliday(initDate) != null) {
// initDate = initDate.plusDays(1);
// }
LocalDate maxCheckdate = (initDate).plusDays(deadlinedays);
while (this.holidaysRepo.findByIdHoliday(maxCheckdate) != null) {
maxCheckdate = maxCheckdate.plusDays(1);
}
int checkDays = Days.daysBetween((new LocalDate()), maxCheckdate).getDays() + deadlinedays;
for (int i = 0; i <= checkDays; i++) { //newDeadlineDays
LocalDate dailyMenuDate = initDate.plusDays(i);
// if old deadline not passed and new deadline passed and dailyMenu not null, send report email
if (menusService.deadlinePassed(dailyMenuDate) && dailyMenuRepo.findByDate(dailyMenuDate) != null) { //
//System.out.println(">>>>>>>>>>>>>sending email, date: " + dailyMenuDate);
eService.sendOrderSummary(dailyMenuDate);
}
}
}
项目:moneytracking
文件:DBHelper.java
public double getAVGExpense(LocalDate start, LocalDate end) {
List<MoneyItem> l = daoSession.getMoneyItemDao().queryBuilder().where(MoneyItemDao.Properties.Amount.lt(0)).where(MoneyItemDao.Properties.Date.between(start.toDate(), end.toDate())).list();
if (l.size() == 0)
return 0.0;
else {
double total = 0.0;
ListIterator<MoneyItem> listIterator = l.listIterator();
while (listIterator.hasNext()) {
total += listIterator.next().getAmount();
}
return total / l.size();
}
}
项目:mbed-cloud-sdk-java
文件:ApiClient.java
@Override
public LocalDate read(JsonReader in) throws IOException {
switch (in.peek()) {
case NULL:
in.nextNull();
return null;
default:
String date = in.nextString();
return formatter.parseLocalDate(date);
}
}
项目:yum
文件:UpdateOrderItems.java
/**
* Get dailyMenuDate
* @return dailyMenuDate
**/
@ApiModelProperty(value = "")
@Valid
public LocalDate getDailyMenuDate() {
return dailyMenuDate;
}
项目:moneytracking
文件:EditActivity.java
private void init_dateinput() {
dateInputText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//To show current date in the datepicker
Calendar mcurrentDate = Calendar.getInstance();
int mYear = mcurrentDate.get(Calendar.YEAR);
int mMonth = mcurrentDate.get(Calendar.MONTH);
int mDay = mcurrentDate.get(Calendar.DAY_OF_MONTH);
DatePickerDialog mDatePicker = new DatePickerDialog(EditActivity.this, new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker datepicker, int selectedyear, int selectedmonth, int selectedday) {
dateInputText.setText(selectedday + "/" + (selectedmonth + 1) + "/" + selectedyear);
}
}, mYear, mMonth, mDay);
mDatePicker.setTitle("Select date");
if (isPlanned) {
LocalDate lo = LocalDate.fromDateFields(new Date());
lo = lo.plusDays(1);
mDatePicker.getDatePicker().setMinDate(lo.toDate().getTime());
} else {
mDatePicker.getDatePicker().setMaxDate(new Date().getTime());
}
mDatePicker.show();
}
});
}
项目:autorest.java
文件:PathsImpl.java
/**
* Get null as date - this should throw or be unusable on the client side, depending on date representation.
*
* @param datePath null as date (should throw)
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceResponse} object if successful.
*/
public Observable<Void> dateNullAsync(LocalDate datePath) {
return dateNullWithServiceResponseAsync(datePath).map(new Func1<ServiceResponse<Void>, Void>() {
@Override
public Void call(ServiceResponse<Void> response) {
return response.body();
}
});
}
项目:moneytracking
文件:DBHelper.java
public double getTotalProfit(LocalDate start, LocalDate end) {
List<MoneyItem> l = daoSession.getMoneyItemDao().queryBuilder().where(MoneyItemDao.Properties.Amount.gt(0)).where(MoneyItemDao.Properties.Date.between(start.toDate(), end.toDate())).list();
double total = 0.0;
ListIterator<MoneyItem> listIterator = l.listIterator();
while (listIterator.hasNext()) {
total += listIterator.next().getAmount();
}
return total;
}
项目:yum
文件:OrdersApiController.java
@Override
@PreAuthorize("hasAuthority('hungry')")
public ResponseEntity<DailyOrder> ordersIdGet(@ApiParam(value = "", required = true) @PathVariable("id") Long id,
@NotNull @ApiParam(value = "", required = true) @RequestParam(value = "dailyMenuId", required = true) Long dailyMenuId,
@NotNull @ApiParam(value = "", required = true) @RequestParam(value = "dailyMenuVersion", required = true) int dailyMenuVersion,
@NotNull @ApiParam(value = "", required = true) @RequestParam(value = "dailyMenuDate", required = true) @DateTimeFormat(pattern = "YYYY-MM-dd") LocalDate dailyMenuDate,
@ApiParam(value = "") @RequestParam(value = "userid", required = false, defaultValue = "0") Long userid) throws ApiException {
DailyOrder dailyOrder = ordersService.ordersIdGet(id, dailyMenuId, dailyMenuVersion, dailyMenuDate, userid);
return new ResponseEntity<>(dailyOrder, HttpStatus.OK);
}
项目:yum
文件:DailyMenu.java
public DailyMenu(long id, List<Food> foods, List<DailyOrder> dailyOrders, LocalDate date, DateTime lastEdit, int version) {
this.id = id;
this.foods = foods;
this.dailyOrders = dailyOrders;
this.date = date;
this.lastEdit = lastEdit;
this.version = version;
}
项目:yum
文件:User.java
public User(long id, List<DailyOrder> dailyOrders, String lastName, String firstName, String email, UserRole userRole, String password, LocalDate registrationDate, boolean approved, DateTime lastEdit, int version) {
this.id = id;
this.dailyOrders = dailyOrders;
this.lastName = lastName;
this.firstName = firstName;
this.email = email;
this.userRole = userRole;
this.password = password;
this.registrationDate = registrationDate;
this.approved = approved;
this.lastEdit = lastEdit;
this.version = version;
}
项目:autorest.java
文件:DictionarysImpl.java
/**
* Get date dictionary value {"0": "2012-01-01", "1": null, "2": "1776-07-04"}.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable to the Map<String, LocalDate> object
*/
public Observable<ServiceResponse<Map<String, LocalDate>>> getDateInvalidNullWithServiceResponseAsync() {
return service.getDateInvalidNull()
.flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Map<String, LocalDate>>>>() {
@Override
public Observable<ServiceResponse<Map<String, LocalDate>>> call(Response<ResponseBody> response) {
try {
ServiceResponse<Map<String, LocalDate>> clientResponse = getDateInvalidNullDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
项目:exam
文件:ExamRoom.java
@Transient
public int getTimezoneOffset(LocalDate date) {
String day = date.dayOfWeek().getAsText(Locale.ENGLISH);
for (DefaultWorkingHours defaultHour : defaultWorkingHours) {
if (defaultHour.getWeekday().equalsIgnoreCase(day)) {
return defaultHour.getTimezoneOffset();
}
}
return 0;
}
项目:verify-matching-service-adapter
文件:MatchingServiceAssertionToAssertionTransformerTest.java
@Test
public void shouldTransformAssertionsWithDateOfBirthAttribute() {
LocalDate dob = new LocalDate(1980, 10, 30);
Attribute attribute = new UserAccountCreationAttributeFactory(openSamlXmlObjectFactory).createUserAccountCreationDateOfBirthAttribute(ImmutableList.of(new SimpleMdsValue<>(dob, null, null, false)));
Assertion assertion = transformAssertionWithAttribute(attribute);
XMLObject firstAttributeValue = assertAssertionAndGetAttributeValue(DATE_OF_BIRTH, assertion);
assertThat(((StringValueSamlObject) firstAttributeValue).getValue()).isEqualTo(dob.toString());
}
项目:webside
文件:DateFormatterUtil.java
/**
* 使用joda替代jdk自带的日期格式化类,因为 DateFormat 和 SimpleDateFormat 类不都是线程安全的
* 确保不会在多线程状态下使用同一个 DateFormat 或者 SimpleDateFormat 实例
* 如果多线程情况下需要访问同一个实例,那么请用同步方法
* 可以使用 joda-time 日期时间处理库来避免这些问题,如果使用java 8, 请切换到 java.time包
* 你也可以使用 commons-lang 包中的 FastDateFormat 工具类
* 另外你也可以使用 ThreadLocal 来处理这个问题
*/
@Override
public Date parse(String text, Locale locale) throws ParseException {
Date date = null;
LocalDate localDate = null;
try {
localDate = LocalDate.parse(text, DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"));
date = localDate.toDate();
} catch (Exception e) {
localDate = LocalDate.parse(text, DateTimeFormat.forPattern("yyyy-MM-dd"));
date = localDate.toDate();
throw e;
}
return date;
}
项目:autorest.java
文件:DatesImpl.java
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: fixtures.bodydate.Dates putMinDate" })
@PUT("date/min")
Observable<Response<ResponseBody>> putMinDate(@Body LocalDate dateBody);
项目:yum
文件:OrdersService.java
private void ConcurrentOrderDeletionCheck(Long dailyMenuId, int dailyMenuVersion, LocalDate dailyMenuDate,
com.jrtechnologies.yum.data.entity.User user, com.jrtechnologies.yum.data.entity.DailyOrder dailyOrderEntity)
throws ApiException {
long userId = user.getId();
ConcurrentOrderDeletion concurrentOrderDeletion = new ConcurrentOrderDeletion();
com.jrtechnologies.yum.api.model.Error error = new com.jrtechnologies.yum.api.model.Error();
concurrentOrderDeletion.setError(error);
error.setError("410");
// If dailyOrder with the specified id does not exist
if ((dailyOrderEntity == null) || (userId != dailyOrderEntity.getUserId())) {
com.jrtechnologies.yum.data.entity.DailyMenu dailyMenuEntity = dailyMenuRep.findById(dailyMenuId);
if (dailyMenuEntity != null) {
com.jrtechnologies.yum.data.entity.DailyOrder newDailyOrderEntity = dailyOrderRep
.findByUserIdAndDailyMenuId(userId, dailyMenuId); //getDailyMenu();
if (newDailyOrderEntity != null) {
error.setMessage("You cancelled this order earlier, and placed again. Here is the new one.");
concurrentOrderDeletion.setDailyMenu(newDailyOrderEntity.toDtoDailyMenu());
throw new ConcurrentDeletionException(410,
"You cancelled this order earlier, and placed again. Here is the new one.",
concurrentOrderDeletion);
} else {
if (dailyMenuVersion != dailyMenuEntity.getVersion()) {
error.setMessage("You cancelled this order earlier, and the menu has changed");
concurrentOrderDeletion.setDailyMenu(dailyMenuEntity.toDtoDailyMenu());
throw new ConcurrentDeletionException(410,
"You cancelled this order earlier, and the menu has changed", concurrentOrderDeletion);
} else {
error.setMessage("You cancelled this order earlier");
concurrentOrderDeletion.setDailyMenu(dailyMenuEntity.toDtoDailyMenu());
throw new ConcurrentDeletionException(410, "You cancelled this order earlier",
concurrentOrderDeletion);
}
}
} else {
com.jrtechnologies.yum.data.entity.DailyMenu newDailyMenuEntity = dailyMenuRep.findByDate(dailyMenuDate);
if (newDailyMenuEntity != null) {
error.setMessage("You cancelled this order earlier, and the menu has changed");
concurrentOrderDeletion.setDailyMenu(newDailyMenuEntity.toDtoDailyMenu());
throw new ConcurrentDeletionException(410,
"You cancelled this order earlier, and the menu has changed", concurrentOrderDeletion);
} else {
error.setError("410");
error.setMessage("You cancelled this order earlier, and the menu has changed");
concurrentOrderDeletion.setDailyMenu(new DailyMenu());
throw new ConcurrentDeletionException(410,
"You cancelled this order earlier, and no menu is proposed anymore",
concurrentOrderDeletion);
}
}
}
}