List of usage examples for org.joda.time.format DateTimeFormatter print
public String print(ReadablePartial partial)
From source file:com.coderoad.automation.common.util.DateUtil.java
License:Open Source License
/** * Format./*w w w. j ava2 s . c om*/ * * @param date the date * @param pattern the pattern * @return the string */ public static String format(Date date, String pattern) { DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); String strDate = fmt.print(new DateTime(date)); return strDate; }
From source file:com.coderoad.automation.common.util.DateUtil.java
License:Open Source License
/** * Format to utc.// w w w . jav a 2 s.c o m * * @param milliseconds the milliseconds * @param pattern the pattern * @return the string */ public static String formatToUTC(Long milliseconds, String pattern) { DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); fmt = fmt.withZoneUTC(); String strDate = fmt.print(new DateTime(milliseconds)); return strDate; }
From source file:com.coderoad.automation.common.util.DateUtil.java
License:Open Source License
/** * Format to zone.//from w w w . j a va 2 s . co m * * @param milliseconds the milliseconds * @param zone the zone * @param pattern the pattern * @return the string */ public static String formatToZone(Long milliseconds, DateTimeZone zone, String pattern) { DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); fmt = fmt.withZone(zone); String strDate = fmt.print(new DateTime(milliseconds)); return strDate; }
From source file:com.datasalt.pangool.examples.movingaverage.MovingAverageGenerateData.java
License:Apache License
public final static void main(String[] args) throws IOException { if (args.length != 3) { System.err.println();//w w w . j a v a 2 s. com System.err.println("Three arguments are needed."); System.err.println("Usage: [out-file] [nRegisters] [nUrls]"); System.err.println(); System.err.println( "Example: url_regs.txt 10 2 -> Will generate a file 'url_regs.txt' with 10 registers from 2 different urls."); System.err.println(); System.exit(-1); } String outFile = args[0]; int nRegisters = Integer.parseInt(args[1]); int nUrls = Integer.parseInt(args[2]); DateTimeFormatter format = DateTimeFormat.forPattern("yyyy-MM-dd"); long now = System.currentTimeMillis(); BufferedWriter writer = new BufferedWriter(new FileWriter(outFile)); for (int i = 0; i < nRegisters; i++) { int urlId = (int) (Math.random() * nUrls); int randomCount = (int) (Math.random() * 10000); writer.write("url" + urlId + "\t" + format.print(now) + "\t" + randomCount + "\n"); now -= 1000 * 60 * 60 * 24; } writer.close(); }
From source file:com.davis.bluefolder.BlueUtils.java
public static String contructDatesForSearch(String start, String end) { DateTimeFormatter fmt = DateTimeFormat.forPattern("MM-dd-yyyy hh:mma"); DateTimeZone timeZone = DateTimeZone.forID("America/New_York"); // Specify or else the JVM's default will apply. DateTime dateTime = new DateTime(new java.util.Date(), timeZone); // Today's Date DateTime pastDate = dateTime.minusDays(14); // 2 weeks ago String endDate = null;//from ww w. java 2s. c om String startDate = null; if (start != null && !start.trim().equalsIgnoreCase("")) { if (end != null && !end.trim().equalsIgnoreCase("")) { startDate = fmt.parseDateTime(start).toString(); endDate = fmt.parseDateTime(end).toString(); } else { endDate = fmt.print(dateTime); startDate = fmt.print(pastDate); } } else { endDate = fmt.print(dateTime); startDate = fmt.print(pastDate); } //dateTimeClosed String date = " <dateRange dateField=\"dateTimeCreated\">" + "<startDate>" + startDate + "</startDate>" + "<endDate>" + endDate + "</endDate>" + "</dateRange>"; return date; }
From source file:com.ecofactor.qa.automation.util.DateUtil.java
License:Open Source License
/** * Gets the current time stamp./*from w w w . j av a2 s. com*/ * @return the current time stamp */ public static String getUTCCurrentTimeStamp() { DateTime startDate = new DateTime(DateTimeZone.UTC); DateTimeFormatter fmt = DateTimeFormat.forPattern(DATE_FMT_FULL); return fmt.print(startDate); }
From source file:com.ecofactor.qa.automation.util.DateUtil.java
License:Open Source License
/** * Gets the uTC current time stamp./*w w w. j ava 2s. com*/ * @param pattern the pattern * @return the uTC current time stamp */ public static String getUTCCurrentTimeStamp(String pattern) { DateTime startDate = new DateTime(DateTimeZone.UTC); DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); return fmt.print(startDate); }
From source file:com.ecofactor.qa.automation.util.DateUtil.java
License:Open Source License
/** * Gets the calendar./* ww w. ja v a2 s . co m*/ * @param startTime the start time * @param minutes the minutes * @return the calendar */ public static Calendar getCalendar(Calendar startTime, int minutes) { Calendar endTime = null; DateTime start = new DateTime(startTime); DateTime end = start.plusMinutes(minutes); DateTimeFormatter fmt = DateTimeFormat.forPattern(DATE_FMT_FULL); fmt = fmt.withZoneUTC(); endTime = parseToUTCCalendar(fmt.print(end), DATE_FMT_FULL); return endTime; }
From source file:com.ecofactor.qa.automation.util.DateUtil.java
License:Open Source License
/** * Format.//from w w w . j a va2s . com * @param calendar the calendar * @param pattern the pattern * @return the string */ public static String formatToUTC(Calendar calendar, String pattern) { DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); fmt = fmt.withZoneUTC(); String strDate = fmt.print(new DateTime(calendar)); LOGGER.debug("UTC Timestamp " + strDate); return strDate; }
From source file:com.ecofactor.qa.automation.util.DateUtil.java
License:Open Source License
/** * Format.//from w w w . j a va2 s .c o m * @param calendar the calendar * @param pattern the pattern * @return the string */ public static String format(Calendar calendar, String pattern) { DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); String strDate = fmt.print(new DateTime(calendar)); return strDate; }