List of usage examples for org.joda.time DateTimeZone UTC
DateTimeZone UTC
To view the source code for org.joda.time DateTimeZone UTC.
Click Source Link
From source file:com.cloudhopper.commons.util.filefilter.FileNameDateTimeFilter.java
License:Apache License
public FileNameDateTimeFilter(DateTime cutoffDate, String pattern, DateTimeZone zone) { this.cutoffDate = cutoffDate; if (pattern == null) { this.pattern = "yyyy-MM-dd"; } else {//from w ww . ja v a 2s . c o m this.pattern = pattern; } if (zone == null) { this.zone = DateTimeZone.UTC; } else { this.zone = zone; } }
From source file:com.cloudhopper.smpp.demo.DeliveryReceiptMain.java
License:Apache License
static public void main(String[] args) throws Exception { //DeliveryReceipt dlr = DeliveryReceipt.parseShortMessage("id:4 sub:001 dlvrd:001 submit date:1006020051 done date:1006020051 stat:DELIVRD err:000 Text:Hello", DateTimeZone.UTC, true); //DeliveryReceipt dlr = DeliveryReceipt.parseShortMessage("sub:001 id:4 dlvrd:001 done date:1006020051 stat:DELIVRD submit date:1006020051 err:000 Text:Hello", DateTimeZone.UTC, true); //DeliveryReceipt dlr = DeliveryReceipt.parseShortMessage("sub:001 id:4 dlvrd:001 done date:1006020051 stat:DELIVRD submit date:1006020051 err:000 text:", DateTimeZone.UTC, true); DeliveryReceipt dlr = DeliveryReceipt.parseShortMessage( "id:2E179B310EDE971B2760C72B7F026E1B submit date:20110314181534 done date:20110314181741 stat:DELIVRD err:0", DateTimeZone.UTC, false); logger.debug("{}", dlr); }
From source file:com.coderoad.automation.common.util.DateUtil.java
License:Open Source License
/** * Checks if is last date./*w w w .j av a2 s. c o m*/ * * @return true, if is last date */ public static boolean isLastDate() { DateTime startDate = new DateTime(DateTimeZone.UTC); int max = startDate.dayOfMonth().getMaximumValue(); int current = startDate.getDayOfMonth(); return current == max; }
From source file:com.coderoad.automation.common.util.DateUtil.java
License:Open Source License
/** * Gets the UTC current time stamp.// w ww. java 2 s . c o m * * @param pattern the pattern * @return the UTC current time stamp */ public static String getUTCCurrentTimeStamp(String pattern) { DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); return fmt.print(new DateTime(DateTimeZone.UTC)); }
From source file:com.coderoad.automation.common.util.DateUtil.java
License:Open Source License
/** * Parses the to utc calendar./*from w w w . ja v a 2 s . co m*/ * * @param timestamp the timestamp * @param pattern the pattern * @return the calendar */ public static Calendar parseToUTCCalendar(String timestamp, String pattern) { DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); fmt = fmt.withZoneUTC(); DateTime dt = fmt.parseDateTime(timestamp); dt = dt.toDateTime(DateTimeZone.UTC); return dt.toCalendar(Locale.ENGLISH); }
From source file:com.cohort.util.Calendar2.java
License:Open Source License
/** * This converts s into a double with epochSeconds. * * @param dateTimeFormat one of the ISO8601 formats above, or a Joda format. * If it starts with "yyyy-MM", sourceTime will be parsed with Calendar2.parseISODateTimeZulu(); * else parse with Joda. /*from www.j a va 2 s . com*/ * @return the epochSeconds value or NaN if trouble */ public static double toEpochSeconds(String sourceTime, String dateTimeFormat) { try { if (dateTimeFormat.startsWith("yyyy-MM")) //parse with Calendar2.parseISODateTime return safeIsoStringToEpochSeconds(sourceTime); //parse with Joda DateTimeFormatter formatter = DateTimeFormat.forPattern(dateTimeFormat).withZone(DateTimeZone.UTC); return formatter.parseMillis(sourceTime) / 1000.0; //thread safe } catch (Throwable t) { if (verbose && sourceTime != null && sourceTime.length() > 0) String2.log(" EDVTimeStamp.sourceTimeToEpochSeconds: Invalid sourceTime=" + sourceTime + " format=" + dateTimeFormat + "\n" + t.toString()); return Double.NaN; } }
From source file:com.cohort.util.Calendar2.java
License:Open Source License
/** * This converts sa into a DoubleArray with epochSeconds. * * @param dateTimeFormat one of the ISO8601 formats above, or a Joda format. * If it starts with "yyyy-MM", sa strings will be parsed with Calendar2.parseISODateTimeZulu(); * else parse with Joda. /* ww w . j a va 2 s .c o m*/ * @return a DoubleArray with the epochSeconds values (any/all will be NaN if touble) */ public static DoubleArray toEpochSeconds(StringArray sa, String dateTimeFormat) { int n = sa.size(); DoubleArray da = new DoubleArray(n, false); if (dateTimeFormat == null || dateTimeFormat.length() == 0) { da.addN(n, Double.NaN); return da; } try { if (dateTimeFormat.startsWith("yyyy-MM")) { //use Calendar2 for (int i = 0; i < n; i++) da.add(safeIsoStringToEpochSeconds(sa.get(i))); } else { //use Joda boolean printError = verbose; DateTimeFormatter formatter = DateTimeFormat.forPattern(dateTimeFormat).withZone(DateTimeZone.UTC); da.addN(n, Double.NaN); for (int i = 0; i < n; i++) { String s = sa.get(i); if (s != null && s.length() > 0) { try { da.set(i, formatter.parseMillis(s) / 1000.0); //thread safe } catch (Throwable t2) { if (printError) { String2.log( " EDVTimeStamp.sourceTimeToEpochSeconds: error while parsing sourceTime=" + s + " with format=" + dateTimeFormat + "\n" + t2.toString()); printError = false; } } } } } } catch (Throwable t) { if (verbose) String2.log(" Calendar2.toEpochSeconds: format=" + dateTimeFormat + ", Unexpected error=" + t.toString()); } return da; }
From source file:com.collective.celos.CronSchedule.java
License:Apache License
public CronSchedule(String cronConfig) { try {/* w ww. j a va 2s . com*/ CronExpression.validateExpression(cronConfig); cronExpression = new CronExpression(cronConfig); cronExpression.setTimeZone(DateTimeZone.UTC.toTimeZone()); } catch (ParseException e) { throw new IllegalArgumentException("Error in cron expression", e); } }
From source file:com.collective.celos.CronSchedule.java
License:Apache License
private DateTime getNextDateTime(DateTime candidate) { Date date = cronExpression.getNextValidTimeAfter(candidate.toDate()); if (date != null) { return new DateTime(date, DateTimeZone.UTC); } else {// w ww . j a va 2 s. c o m return null; } }
From source file:com.collective.celos.ScheduledTime.java
License:Apache License
public ScheduledTime(DateTime dateTime) { this.dateTime = Util.requireNonNull(dateTime); if (!dateTime.getZone().equals(DateTimeZone.UTC)) { throw new IllegalArgumentException("Scheduled time must be in UTC, but isn't: " + dateTime); }/*from w w w .java 2s. c o m*/ }