List of usage examples for org.joda.time DateTime toString
public String toString(String pattern)
From source file:com.google.soxlib.Utility.java
License:Apache License
/** * Get the time now in a string format suitable for use in SOX timestamp * fields.// ww w . j ava 2 s . c o m * * @return UTC timestamp to the nearest millisecond as a string. */ public static final String getTimestampNow() { DateTime now = new DateTime(DateTimeZone.UTC); return now.toString(ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC)); }
From source file:com.google.soxlib.Utility.java
License:Apache License
/** * Convert from "unix time" (utc milliseconds since 1970) into a string format * for use in SOX timestamp fields.//w ww. j a v a 2s . c o m * * @param timestampMsUtc utc time in milliseconds since Jan 1, 1970 (aka unix * time). * @return UTC timestamp to the nearest millisecond as a string. */ public static final String getTimestampFromUnixTime(long timestampMsUtc) { DateTime dt = new DateTime(timestampMsUtc, DateTimeZone.UTC); return dt.toString(ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC)); }
From source file:com.google.soxlib.Utility.java
License:Apache License
/** * Verify that the string provided is a valid RFC 3339 timestamp string and * converts the string into the UTC timezone for use by the SOX library. * * @param timestamp string to be verified. * @return timestamp converted to UTC in the SOX format. * @throws IllegalArgumentException if the string cannot be converted to UTC. *///from w w w. j a v a2 s . c o m public static final String verifyTimestamp(String timestamp) throws IllegalArgumentException { Matcher m = Utility.SIMPLE_TIMESTAMP_CHECK.matcher(timestamp); if (!m.find()) { throw new IllegalArgumentException("timestamp not valid"); } // convert entered value to the ISO standard and make that // the official value DateTime dt; try { dt = new DateTime(timestamp); } catch (IllegalArgumentException e) { throw new IllegalArgumentException("timestamp not valid"); } return dt.toString(ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC)); }
From source file:com.googlecode.fascinator.common.StorageDataUtil.java
License:Open Source License
/** * Reformat the date to the format supplied. * * @param dateTimeInput Datetime to clean * @return String The cleaned value//from ww w.ja v a 2s.co m */ public String getDateTime(String dateTimeInput, String outputFormat) { String formattedDateTimeOutput = StringUtils.EMPTY; if (StringUtils.isNotBlank(dateTimeInput)) { DateTime dateTime = new DateTime(dateTimeInput); if (StringUtils.isNotBlank(outputFormat)) { formattedDateTimeOutput = dateTime.toString(outputFormat); } else { formattedDateTimeOutput = dateTime.toString(); } log.debug("date text was: " + dateTimeInput); log.debug("date time output format is: " + outputFormat); log.debug("Returning date time: " + formattedDateTimeOutput); } return formattedDateTimeOutput; }
From source file:com.grepcurl.random.BaseGenerator.java
License:Apache License
public Date randomDate(String fromDate) { Validate.notNull(fromDate);/* w w w . ja va2 s .c om*/ DateTime now = new DateTime(new Date()); return randomDate(fromDate, now.toString(_dateTimeFormatter)); }
From source file:com.grepcurl.random.BaseGenerator.java
License:Apache License
public Date randomDate() { DateTime epoch = new DateTime(0L); DateTime now = new DateTime(new Date()); return randomDate(epoch.toString(_dateTimeFormatter), now.toString(_dateTimeFormatter)); }
From source file:com.hangum.tadpole.engine.utils.TimeZoneUtil.java
License:Open Source License
/** * db? timezone ? ?? ./*from www . j ava 2s. c o m*/ * * @param date * @return */ public static String dateToStr(Date date) { String dbTimeZone = GetAdminPreference.getDBTimezone(); // db? timezone . if (StringUtils.isEmpty(dbTimeZone)) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return sdf.format(date); } else { // UTC . DateTime targetDateTime = new DateTime(date).withZone(DateTimeZone.forID(SessionManager.getTimezone())); String strPretty = targetDateTime.toString(prettyDateTimeFormater()); // if(logger.isDebugEnabled()) { // logger.debug(String.format("[SessionManager dbTimezone] %s => %s", SessionManager.getTimezone(), targetDateTime)); // logger.debug(String.format("[strPretty] %s", strPretty)); // logger.debug("==============================================================="); // } return strPretty; } }
From source file:com.hotwire.selenium.tools.c3.customer.lpg.LPGRefundRequestForm.java
License:Open Source License
public void fill(Double totalAmount, boolean isOpaque) { //Choose price must be less than Hotwire price String lowerPrice = new DecimalFormat("###.##").format(totalAmount - PRICE_DIFF); setText("input[name='competitorPrice']", lowerPrice); //Date found/*from w w w . java2 s.c o m*/ setDateFound(); //Time before now on 3 hours DateTime timeFound = getTimeBefore(5); selectValue("select#hour", timeFound.toString("h")); selectValue("select#minute", timeFound.toString("mm")); selectValue("select#amOrPm", "AM"); //Any source setText("textarea#competitorPriceSource", "Test"); try { //Fill addresses setText("input#customerAddress1", "test"); setText("input#customerAddress2", "test"); setText("input#customerCity", "test"); selectValue("select#customerState", "AA"); setText("input#customerZipCode", "10005"); logger.info("RETAIL PURCHASE"); } catch (NoSuchElementException e) { logger.info("OPAQUE PURCHASE"); } }
From source file:com.infinities.skyport.compute.entity.adapter.ISO8601DateAdapter.java
License:Apache License
@Override public String marshal(Date v) throws Exception { try {/*www .j av a 2s.c o m*/ // DateFormat format = iso8601Format.get(); // return format.format(v); DateTime dt = new DateTime(v); dt.withZone(timeZone); return dt.toString(outputFormatter); } catch (Exception e) { logger.warn("Failed to format date {}", v.toString()); return null; } }
From source file:com.inspireon.dragonfly.common.logging.ExtendedDailyRollingFileAppender.java
License:Apache License
public void activateOptions() { super.activateOptions(); if ((datePattern != null) && (fileName != null)) { // lastCheck.setTime(System.currentTimeMillis()); lastCheck = new DateTime(); datePatternFormat = new SimpleDateFormat(datePattern); int type = computeCheckPeriod(); printPeriodicity(type);/*from w w w . ja v a2 s. co m*/ rollingCalendar.setType(type); File file = new File(fileName); DateTime lastModifiedDate = new DateTime(file.lastModified()); scheduledFilename = fileName + lastModifiedDate.toString(DateTimeFormat.forPattern(datePattern)); // datePatternFormat.format(new Date(file.lastModified())); } else { LogLog.error("Either File or DatePattern options are not set for appender [" + name + "]."); } }