List of usage examples for org.joda.time DateTime toDateTime
public DateTime toDateTime(Chronology chronology)
this
if possible. From source file:com.microsoft.azure.keyvault.models.Attributes.java
License:Open Source License
/** * Set the notBefore value.//from w w w.ja va 2s . co m * * @param notBefore the notBefore value to set * @return the Attributes object itself. */ public Attributes withNotBefore(DateTime notBefore) { if (notBefore == null) { this.notBefore = null; } else { this.notBefore = notBefore.toDateTime(DateTimeZone.UTC).getMillis() / 1000; } return this; }
From source file:com.microsoft.azure.keyvault.models.Attributes.java
License:Open Source License
/** * Set the expires value./*from w w w . j av a 2s . c o m*/ * * @param expires the expires value to set * @return the Attributes object itself. */ public Attributes withExpires(DateTime expires) { if (expires == null) { this.expires = null; } else { this.expires = expires.toDateTime(DateTimeZone.UTC).getMillis() / 1000; } return this; }
From source file:com.mycollab.core.utils.DateTimeUtils.java
License:Open Source License
public static Date convertDateTimeByTimezone(Date date, TimeZone timeZone) { DateTime dateTime = new DateTime(date); return dateTime.toDateTime(DateTimeZone.forTimeZone(timeZone)).toLocalDateTime().toDate(); }
From source file:com.mycollab.vaadin.web.ui.field.DateTimeOptionField.java
License:Open Source License
@Override public void setPropertyDataSource(Property newDataSource) { Date value = (Date) newDataSource.getValue(); if (value != null) { DateTime jodaTime = new DateTime(value); jodaTime = jodaTime.toDateTime(DateTimeZone.forTimeZone(UserUIContext.getUserTimeZone())); int hrs = jodaTime.getHourOfDay(); int min = jodaTime.getMinuteOfHour(); String timeFormat = "AM"; if (hrs > 12) { hrs -= 12;//from w ww . j av a 2 s .c om timeFormat = "PM"; } if ((hrs > 0 || min > 0) && hideTimeOption) { toggleHideTimeOption(false); } popupDateField.setPropertyDataSource(new ObjectProperty(jodaTime.toDate())); if (!hideTimeOption) { hourPickerComboBox.setPropertyDataSource(new ObjectProperty((hrs < 10) ? "0" + hrs : "" + hrs)); minutePickerComboBox.setPropertyDataSource(new ObjectProperty((min < 10) ? "0" + min : "" + min)); timeFormatComboBox.setPropertyDataSource(new ObjectProperty(timeFormat)); } } super.setPropertyDataSource(newDataSource); }
From source file:com.mycompany.conceptestsring.JodaDateT.java
public static void main(String[] arg) { DateTime dt = new DateTime(); DateTimeZone dtZone = DateTimeZone.forID("Europe/London"); System.out.println("dtZone = " + dtZone + " date" + dt.toDateTime(dtZone)); System.out.println("dt = " + dt + dt.getZone()); }
From source file:com.ning.arecibo.util.timeline.DateTimeUtils.java
License:Apache License
public static int unixSeconds(final DateTime dateTime) { final long millis = dateTime.toDateTime(DateTimeZone.UTC).getMillis(); return (int) (millis / 1000L); }
From source file:com.ning.billing.jaxrs.resources.InvoiceResource.java
License:Apache License
@POST @Consumes(APPLICATION_JSON)//from w w w .jav a 2 s .co m @Produces(APPLICATION_JSON) public Response createFutureInvoice(@QueryParam(QUERY_ACCOUNT_ID) final String accountId, @QueryParam(QUERY_TARGET_DATE) final String targetDateTime, @QueryParam(QUERY_DRY_RUN) @DefaultValue("false") final Boolean dryRun, @HeaderParam(HDR_CREATED_BY) final String createdBy, @HeaderParam(HDR_REASON) final String reason, @HeaderParam(HDR_COMMENT) final String comment, @javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException, InvoiceApiException { final CallContext callContext = context.createContext(createdBy, reason, comment, request); final Account account = accountApi.getAccountById(UUID.fromString(accountId), callContext); final DateTime inputDateTime = targetDateTime != null ? DATE_TIME_FORMATTER.parseDateTime(targetDateTime) : clock.getUTCNow(); final LocalDate inputDate = inputDateTime.toDateTime(account.getTimeZone()).toLocalDate(); final Invoice generatedInvoice = invoiceApi.triggerInvoiceGeneration(UUID.fromString(accountId), inputDate, dryRun, callContext); if (dryRun) { return Response.status(Status.OK).entity(new InvoiceJsonSimple(generatedInvoice)).build(); } else { return uriBuilder.buildResponse(InvoiceResource.class, "getInvoice", generatedInvoice.getId()); } }
From source file:com.ning.billing.jaxrs.resources.InvoiceResource.java
License:Apache License
@POST @Path("/{invoiceId:" + UUID_PATTERN + "}") @Consumes(APPLICATION_JSON)/* w ww . j a va 2 s . co m*/ @Produces(APPLICATION_JSON) public Response adjustInvoiceItem(final InvoiceItemJsonSimple json, @PathParam("invoiceId") final String invoiceId, @QueryParam(QUERY_REQUESTED_DT) final String requestedDateTimeString, @HeaderParam(HDR_CREATED_BY) final String createdBy, @HeaderParam(HDR_REASON) final String reason, @HeaderParam(HDR_COMMENT) final String comment, @javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException, InvoiceApiException { final CallContext callContext = context.createContext(createdBy, reason, comment, request); final Account account = accountApi.getAccountById(UUID.fromString(json.getAccountId()), callContext); // Get the effective date of the adjustment, in the account timezone final LocalDate requestedDate; if (requestedDateTimeString == null) { requestedDate = clock.getUTCToday(); } else { final DateTime requestedDateTime = DATE_TIME_FORMATTER.parseDateTime(requestedDateTimeString); requestedDate = requestedDateTime.toDateTime(account.getTimeZone()).toLocalDate(); } final InvoiceItem adjustmentItem; if (json.getAmount() == null) { adjustmentItem = invoiceApi.insertInvoiceItemAdjustment(account.getId(), UUID.fromString(invoiceId), UUID.fromString(json.getInvoiceItemId()), requestedDate, callContext); } else { adjustmentItem = invoiceApi.insertInvoiceItemAdjustment(account.getId(), UUID.fromString(invoiceId), UUID.fromString(json.getInvoiceItemId()), requestedDate, json.getAmount(), json.getCurrency(), callContext); } return uriBuilder.buildResponse(InvoiceResource.class, "getInvoice", adjustmentItem.getInvoiceId()); }
From source file:com.ning.billing.jaxrs.resources.InvoiceResource.java
License:Apache License
@POST @Produces(APPLICATION_JSON)/* ww w. j ava 2 s. c o m*/ @Consumes(APPLICATION_JSON) @Path(CHARGES) public Response createExternalCharge(final InvoiceItemJsonSimple externalChargeJson, @QueryParam(QUERY_REQUESTED_DT) final String requestedDateTimeString, @HeaderParam(HDR_CREATED_BY) final String createdBy, @HeaderParam(HDR_REASON) final String reason, @HeaderParam(HDR_COMMENT) final String comment, @javax.ws.rs.core.Context final UriInfo uriInfo, @javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException, InvoiceApiException { final CallContext callContext = context.createContext(createdBy, reason, comment, request); final Account account = accountApi.getAccountById(UUID.fromString(externalChargeJson.getAccountId()), callContext); // Get the effective date of the external charge, in the account timezone final LocalDate requestedDate; if (requestedDateTimeString == null) { requestedDate = clock.getUTCToday(); } else { final DateTime requestedDateTime = DATE_TIME_FORMATTER.parseDateTime(requestedDateTimeString); requestedDate = requestedDateTime.toDateTime(account.getTimeZone()).toLocalDate(); } final Currency currency = Objects.firstNonNull(externalChargeJson.getCurrency(), account.getCurrency()); final InvoiceItem externalCharge; if (externalChargeJson.getBundleId() != null) { externalCharge = invoiceApi.insertExternalChargeForBundle(account.getId(), UUID.fromString(externalChargeJson.getBundleId()), externalChargeJson.getAmount(), externalChargeJson.getDescription(), requestedDate, currency, callContext); } else { externalCharge = invoiceApi.insertExternalCharge(account.getId(), externalChargeJson.getAmount(), externalChargeJson.getDescription(), requestedDate, currency, callContext); } return uriBuilder.buildResponse(InvoiceResource.class, "getInvoice", externalCharge.getInvoiceId(), uriInfo.getBaseUri().toString()); }
From source file:com.ning.billing.jaxrs.resources.InvoiceResource.java
License:Apache License
@POST @Produces(APPLICATION_JSON)//from w ww. ja v a 2 s . com @Consumes(APPLICATION_JSON) @Path("/{invoiceId:" + UUID_PATTERN + "}/" + CHARGES) public Response createExternalChargeForInvoice(final InvoiceItemJsonSimple externalChargeJson, @PathParam("invoiceId") final String invoiceIdString, @QueryParam(QUERY_REQUESTED_DT) final String requestedDateTimeString, @HeaderParam(HDR_CREATED_BY) final String createdBy, @HeaderParam(HDR_REASON) final String reason, @HeaderParam(HDR_COMMENT) final String comment, @javax.ws.rs.core.Context final UriInfo uriInfo, @javax.ws.rs.core.Context final HttpServletRequest request) throws AccountApiException, InvoiceApiException { final CallContext callContext = context.createContext(createdBy, reason, comment, request); final Account account = accountApi.getAccountById(UUID.fromString(externalChargeJson.getAccountId()), callContext); // Get the effective date of the external charge, in the account timezone final LocalDate requestedDate; if (requestedDateTimeString == null) { requestedDate = clock.getUTCToday(); } else { final DateTime requestedDateTime = DATE_TIME_FORMATTER.parseDateTime(requestedDateTimeString); requestedDate = requestedDateTime.toDateTime(account.getTimeZone()).toLocalDate(); } final UUID invoiceId = UUID.fromString(invoiceIdString); final Currency currency = Objects.firstNonNull(externalChargeJson.getCurrency(), account.getCurrency()); final InvoiceItem externalCharge; if (externalChargeJson.getBundleId() != null) { externalCharge = invoiceApi.insertExternalChargeForInvoiceAndBundle(account.getId(), invoiceId, UUID.fromString(externalChargeJson.getBundleId()), externalChargeJson.getAmount(), externalChargeJson.getDescription(), requestedDate, currency, callContext); } else { externalCharge = invoiceApi.insertExternalChargeForInvoice(account.getId(), invoiceId, externalChargeJson.getAmount(), externalChargeJson.getDescription(), requestedDate, currency, callContext); } return uriBuilder.buildResponse(InvoiceResource.class, "getInvoice", externalCharge.getInvoiceId(), uriInfo.getBaseUri().toString()); }