List of usage examples for org.joda.time.format DateTimeFormat forPattern
public static DateTimeFormatter forPattern(String pattern)
From source file:com.helger.datetime.format.PDTFormatter.java
License:Apache License
/** * Get the {@link DateTimeFormatter} for the given pattern and locale, using * our default chronology./*from w w w.java 2 s. c o m*/ * * @param sPattern * The pattern to be parsed * @param aDisplayLocale * The locale to be used. May be <code>null</code>. * @return The formatter object. * @throws IllegalArgumentException * If the pattern is illegal */ @Nonnull public static DateTimeFormatter getForPattern(@Nonnull final String sPattern, @Nullable final Locale aDisplayLocale) throws IllegalArgumentException { return getWithLocaleAndChrono(DateTimeFormat.forPattern(sPattern), aDisplayLocale); }
From source file:com.helger.datetime.format.SerializableDateTimeFormatter.java
License:Apache License
@Nonnull private static DateTimeFormatter _createFormatter(@Nonnull final String sPattern, @Nullable final Locale aLocale) { return PDTFormatter.getWithLocaleAndChrono(DateTimeFormat.forPattern(sPattern), aLocale); }
From source file:com.hihexo.epp.controller.NSDomainController.java
License:Open Source License
/** * <code>NSDomain.sendDomainRenew</code> command. *//*from w ww . ja v a 2s . com*/ @ApiOperation(value = "renew", notes = "") @RequestMapping(value = "/renew", method = RequestMethod.POST) @SystemControllerLog(description = "??") @ResponseBody public ResultVo doDomainRenew(HttpServletRequest request, @RequestBody NSDomainRenewParam params) { printStart("doDomainRenew"); EPPSession theSession = null; EPPDomainRenewResp theResponse = null; try { theSession = this.borrowSession(); com.verisign.epp.namestore.interfaces.NSDomain theDomain = new com.verisign.epp.namestore.interfaces.NSDomain( theSession); try { theDomain.setTransId(getClientTransId(request)); String theDomainName = this.makeDomainName(); logger.debug("\ndomainRenew: Domain " + theDomainName + " renew"); theDomain.addDomainName(params.getDomainName()); theDomain.setSubProductID(params.getDomainProductID()); DateTimeFormatter format = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); DateTime dateTime = DateTime.parse(params.getExpiretime(), format); theDomain.setExpirationDate(dateTime.toDate()); theDomain.setPeriodLength(params.getPeriod()); theDomain.setPeriodUnit(params.getPeriodUnit()); if (StringUtils.isNotEmpty(params.getAllocationToken())) { theDomain.setAllocationToken(params.getAllocationToken()); } theResponse = theDomain.sendRenew(); // -- Output all of the response attributes logger.debug("domainRenew: Response = [" + theResponse + "]\n\n"); // -- Output response attributes using accessors logger.debug("domainRenew: name = " + theResponse.getName()); logger.debug("domainRenew: expiration date = " + theResponse.getExpirationDate()); } catch (EPPCommandException ex) { TestUtil.handleException(theSession, ex); return renderError(ex.getMessage()); } this.handleResponse(theResponse); return renderSuccess(theResponse); } catch (InvalidateSessionException ex) { this.invalidateSession(theSession); theSession = null; } finally { if (theSession != null) this.returnSession(theSession); } printEnd("doDomainRenew"); return renderError("unknown"); }
From source file:com.hihexo.epp.controller.NSDomainController.java
License:Open Source License
/** * <code>NSDomain.sendRestoreReport</code> command. */// w w w .ja va 2 s . co m @ApiOperation(value = "?????", notes = "") @RequestMapping(value = "/restorereport", method = RequestMethod.POST) @SystemControllerLog(description = "restore") @ResponseBody public ResultVo doDomainRestoreReport(HttpServletRequest request, @RequestBody NSDomainRestoreReportParam params) { printStart("doDomainRestoreReport"); EPPSession theSession = null; EPPResponse theResponse = null; try { theSession = this.borrowSession(); com.verisign.epp.namestore.interfaces.NSDomain theDomain = new com.verisign.epp.namestore.interfaces.NSDomain( theSession); String theDomainName = params.getDomainName(); try { theDomain.setTransId(getClientTransId(request)); logger.debug("\ndomainRestoreReport: Domain " + theDomainName + " restore request"); theDomain.addDomainName(theDomainName); theDomain.setSubProductID(params.getDomainProductID()); EPPRgpExtReport theReport = new EPPRgpExtReport(); theReport.setPreData(params.getPreData()); theReport.setPostData(params.getPostData()); DateTimeFormatter format = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); DateTime dateTime = DateTime.parse(params.getDeleteTime(), format); theReport.setDeleteTime(dateTime.toDate()); dateTime = DateTime.parse(params.getRestoreTime(), format); theReport.setRestoreTime(dateTime.toDate()); theReport.setRestoreReason(new EPPRgpExtReportText(params.getRestoreReason())); theReport.setStatement1(new EPPRgpExtReportText(params.getRestoreStatement1())); theReport.setStatement2(new EPPRgpExtReportText(params.getRestoreStatement2())); theReport.setOther(params.getOtherStuff()); // Execute restore report theDomain.setReport(theReport); theResponse = theDomain.sendRestoreReport(); // -- Output all of the response attributes logger.debug("domainRestoreReport: Response = [" + theResponse + "]\n\n"); this.handleResponse(theResponse); return renderSuccess(theResponse); } catch (EPPCommandException ex) { TestUtil.handleException(theSession, ex); return renderError(ex.getMessage()); } } catch (InvalidateSessionException ex) { this.invalidateSession(theSession); theSession = null; } finally { if (theSession != null) this.returnSession(theSession); } printEnd("doDomainRestoreReport"); return renderError("fail"); }
From source file:com.hmsinc.epicenter.velocity.DateTimeFormatTool.java
License:Open Source License
/** * Checks a string to see if it matches one of the standard DateTimeFormat * style patterns: full, long, medium, short, or default. *//*from ww w. j a v a2s . c o m*/ private static DateTimeFormatter getDateStyle(String style, Locale locale, DateTimeZone zone) { final DateTimeFormatter ret; if (style.equalsIgnoreCase("full")) { ret = DateTimeFormat.fullDate(); } else if (style.equalsIgnoreCase("long")) { ret = DateTimeFormat.longDate(); } else if (style.equalsIgnoreCase("medium")) { ret = DateTimeFormat.mediumDate(); } else if (style.equalsIgnoreCase("short")) { ret = DateTimeFormat.shortDate(); } else if (style.equalsIgnoreCase("none")) { ret = null; } else { ret = DateTimeFormat.forPattern(style); } return ret == null ? null : ret.withLocale(locale).withZone(zone); }
From source file:com.hmsinc.epicenter.velocity.DateTimeFormatTool.java
License:Open Source License
/** * Checks a string to see if it matches one of the standard DateTimeFormat * style patterns: full, long, medium, short, or default. *//*w w w . j a v a 2s . c om*/ private static DateTimeFormatter getTimeStyle(String style, Locale locale, DateTimeZone zone) { final DateTimeFormatter ret; if (style.equalsIgnoreCase("full")) { ret = DateTimeFormat.fullTime(); } else if (style.equalsIgnoreCase("long")) { ret = DateTimeFormat.longTime(); } else if (style.equalsIgnoreCase("medium")) { ret = DateTimeFormat.mediumTime(); } else if (style.equalsIgnoreCase("short")) { ret = DateTimeFormat.shortTime(); } else if (style.equalsIgnoreCase("none")) { ret = null; } else { ret = DateTimeFormat.forPattern(style); } return ret == null ? null : ret; }
From source file:com.hmsinc.epicenter.velocity.DateTimeFormatTool.java
License:Open Source License
/** * Checks a string to see if it matches one of the standard DateTimeFormat * style patterns: full, long, medium, short, or default. *///from ww w . j ava 2 s .c o m private static DateTimeFormatter getDateTimeStyle(String dateStyle, String timeStyle, Locale locale, DateTimeZone zone) { final DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder(); final DateTimeFormatter date = getDateStyle(dateStyle, locale, zone); if (date != null) { builder.append(date); } final DateTimeFormatter time = getTimeStyle(timeStyle, locale, zone); if (date != null && time != null) { builder.append(DateTimeFormat.forPattern(" ")); } if (time != null) { builder.append(time); } return builder.toFormatter(); }
From source file:com.hotwire.selenium.bex.BexAbstractPage.java
License:Open Source License
protected String convertToAmPm(DateTime time2Convert) { DateTimeFormatter fmt = DateTimeFormat.forPattern("h:mm aa"); return fmt.print(time2Convert); }
From source file:com.hotwire.test.steps.tools.bean.CustomerInfo.java
License:Open Source License
public void setCustomerInformation(Map customerInformation) { setCustomerName(customerInformation); this.email = getValue(customerInformation, "EMAIL"); this.accountCreated = DateTimeFormat.forPattern("yyyy-MM-dd") .parseDateTime(getValue(customerInformation, "CREATE_DATE").replaceAll(" .*$", "")); this.phoneNumber = getValue(customerInformation, "PHONE"); this.altPhone = getValue(customerInformation, "ALTERNATE_PHONE"); this.zipCode = getValue(customerInformation, "REGISTER_ZIP"); this.countryCode = getValue(customerInformation, "REGISTER_COUNTRY_CODE"); this.country = getValue(customerInformation, "COUNTRY"); }
From source file:com.hotwire.test.steps.tools.c3.customer.account.C3CustomerAccModel.java
License:Open Source License
public void verifyCustomerInformation() { final C3CustomerInfoFragment c3CustomerInfoFragment = new C3CustomerInfoFragment(getWebdriverInstance()); assertThat(c3CustomerInfoFragment.getName()) .isEqualTo(customerInfo.getFullName().replaceFirst("\\s+", " ")); assertThat(c3CustomerInfoFragment.getEmail()).isEqualTo(customerInfo.getEmail()); //Comparing dates, skipping time DateTime accountCreated = DateTimeFormat.forPattern("dd-MMM-yy") .parseDateTime(c3CustomerInfoFragment.getAccountCreated().replaceAll(" .*$", "")); assertThat(accountCreated).isEqualTo(customerInfo.getAccountCreated()); //Phones verification assertThat(extractPhone(c3CustomerInfoFragment.getPhoneNumber())) .isEqualTo(extractPhone(customerInfo.getPhoneNumber())); if (!"".equals(customerInfo.getAltPhone())) { assertThat(extractPhone(c3CustomerInfoFragment.getAltPhoneNumber())) .isEqualTo(extractPhone(customerInfo.getAltPhone())); }/*from ww w. jav a 2 s .c o m*/ assertThat(c3CustomerInfoFragment.getZip()).isEqualTo(customerInfo.getZipCode()); // final String customerCountry = c3CustomerInfoFragment.getCountry(); // assertThat(customerCountry).isEqualTo(customerInfo.getCountry()); }