/** * Default expiration date construction. * Some Payment Gateways may require a different format. Override if necessary or set the property * "gateway.config.global.expDateFormat" with a format string to provide the correct format for the configured gateway. * @param expMonth * @param expYear * @return */ protected String constructExpirationDate(Integer expMonth, Integer expYear) { SimpleDateFormat sdf = new SimpleDateFormat(getGatewayExpirationDateFormat()); DateTime exp = new DateTime() .withYear(expYear) .withMonthOfYear(expMonth); return sdf.format(exp.toDate()); }
DateTime fixed = date.withYear(year);
private boolean isInSchoolYear(DateTime now, DateTime schoolYearStart, DateTime schoolYearEnd){ int thisYear = now.getYear(); schoolYearStart = schoolYearStart.withYear(thisYear); schoolYearEnd = schoolYearEnd.withYear(thisYear); if(schoolYearStart.isBefore(schoolYearEnd)){ return new Interval(schoolYearStart, schoolYearEnd).contains(now); } else{ return !(new Interval(schoolYearEnd, schoolYearStart).contains(now)); } }
DateTime min = new DateTime(2014, 1, 1, 0, 0); DateTime max = new DateTime(2015, 1, 1, 0, 0).minusMillis(1); Chronology chronology = LimitChronology.getInstance(ISOChronology.getInstance(), min, max); DateTime now = DateTime.now(chronology); System.out.println(now.toString(DateTimeFormat.fullDateTime())); // output: Donnerstag, 6. November 2014 19:08 Uhr MEZ DateTime test = new DateTime(1970, 1, 1, 0, 0).withChronology(chronology); System.out.println(test.toString(DateTimeFormat.fullDateTime())); // no exception! => output: �, �. � ���� ��:�� Uhr MEZ test = now.withYear(1970); // IllegalArgumentException: // The resulting instant is below the supported minimum of // 2014-01-01T00:00:00.000+01:00 (ISOChronology[Europe/Berlin])
/** * 生成有效期限:20150906-20350906 * Valid Through */ public static String generateValidPeriod() { DateTime beginDate =new DateTime(randomDate()) ; String formater = "yyyyMMdd"; DateTime endDate = beginDate.withYear(beginDate.getYear() + 20); return beginDate.toString(formater) + "-" + endDate.toString(formater); }
DateTime dt = new DateTime(); DateTime year2000 = dt.withYear(2000); DateTime oneMonthBefore = dt.minusMonths(1); DateTimeFormatter fmt = ...; String d = dt.toString(fmt);
@Override protected String getSingleItemDescription(String expression) { return new DateTime().withYear(Integer.parseInt(expression)).toString("yyyy", I18nMessages.getCurrentLocale()); }
public static Date getDateFromYearAndKausi(Integer year, String kausi) { Integer month = 1; // kevät by default if (kausi != null && SYKSY_URI.split("#")[0].equals(kausi.split("#")[0])) { month = 8; } return new DateTime().withYear(year).withMonthOfYear(month).withDayOfMonth(1).toDate(); }
DateTime dt = new DateTime(); dt = dt.withYear(year); dt = dt.withWeekOfWeekyear(weekOfYear); dt = dt.withDayOfWeek(weekDay); DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("yyMMdd"); System.out.println(dateTimeFormatter.print(dt));
DateTime dt = new DateTime(); dt = dt.withYear(2015); dt = dt.withWeekOfWeekyear(10); dt = dt.withDayOfWeek(3);
static DateTime civilImpl(ThreadContext context, IRubyObject year) { int y = getYear(year); final DateTime dt; try { dt = defaultDateTime.withYear(y); } catch (IllegalArgumentException ex) { throw context.runtime.newArgumentError("invalid date"); } return dt; }
static DateTime civilImpl(ThreadContext context, IRubyObject year) { int y = getYear(year); final DateTime dt; try { dt = defaultDateTime.withYear(y); } catch (IllegalArgumentException ex) { throw context.runtime.newArgumentError("invalid date"); } return dt; }
public static DateTime getDateTime(final double date, final boolean use1904windowing) { final Calendar c = ExcelDateUtil.getJavaCalendar(date, use1904windowing); if (c == null) { return null; } return new DateTime().withYear(c.get(Calendar.YEAR)).withMonthOfYear(c.get(Calendar.MONTH) + 1).withDayOfMonth(c.get(Calendar.DAY_OF_MONTH)) .withMillisOfDay(0); } }
public static DateTime getDateTime(final double date, final boolean use1904windowing) { final Calendar c = ExcelDateUtil.getJavaCalendar(date, use1904windowing); if (c == null) { return null; } return new DateTime().withYear(c.get(Calendar.YEAR)).withMonthOfYear(c.get(Calendar.MONTH) + 1).withDayOfMonth(c.get(Calendar.DAY_OF_MONTH)) .withMillisOfDay(0); } }
@Override public DateTime truncate(DateTime time) { int year = (int) Math.round(Math.floor(time.year().get() / 10.0)) * 10; return time.year().roundFloorCopy().withYear(year); } };
public DateTime getDate() { return new DateTime().withMonthOfYear(getSelectedMonthNumber()).withYear(getSelectedYearNumber()); }
/** * Sets <code>timeToAdjust</code> to the same year and week-of-year as <code>day</code>. * @param day the day to adjust to * @param timeToAdjust the time to be adjusted * @param midnightOnNextDay if <code>true</code> treats midnight (0:00h) as belonging to the next day. * Otherwise 0:00h is treated as being the start of the current day. */ public static DateTime adjustToSameDay(final DateTime day, final DateTime timeToAdjust, final boolean midnightOnNextDay) { DateTime result = timeToAdjust.withYear(day.getYear()).withDayOfYear(day.getDayOfYear()); if (midnightOnNextDay && result.getHourOfDay() == 0 && result.getMinuteOfHour() == 0) { result = result.plusDays(1); } return result; }
private long[] getMinCountsForHour(String name, int year, int month, int day, int hour) { DateTime dt = new DateTime().withYear(year).withMonthOfYear(month).withDayOfMonth(day).withHourOfDay(hour); AggregateKeyGenerator akg = new AggregateKeyGenerator( AGGREGATE_COUNTER_KEY_PREFIX, name, dt); return convertToArray(getEntries(akg.getHourKey()), 60, false); }
private long[] getMinCountsForHour(String name, int year, int month, int day, int hour) { DateTime dt = new DateTime().withYear(year).withMonthOfYear(month).withDayOfMonth(day).withHourOfDay(hour); AggregateKeyGenerator akg = new AggregateKeyGenerator(REPO_PREFIX, name, dt); return convertToArray(getEntries(akg.getHourKey()), 60, false); }
@Test public void shouldAddJarInfoAndRemoveContainerInfo() { when(configuration.isFrameworkUseDocker()).thenReturn(false); String address = "http://localhost:1234"; when(configuration.getFrameworkFileServerAddress()).thenReturn(address); when(configuration.nativeCommand(any())).thenReturn("ls"); TaskInfoFactory factory = new TaskInfoFactory(clusterState); Date now = new DateTime().withDayOfMonth(1).withDayOfYear(1).withYear(1970).withHourOfDay(1).withMinuteOfHour(2).withSecondOfMinute(3).withMillisOfSecond(400).toDate(); when(clock.now()).thenReturn(now); when(clock.nowUTC()).thenReturn(ZonedDateTime.now(ZoneOffset.UTC)); Protos.TaskInfo taskInfo = factory.createTask(configuration, frameworkState, getOffer(frameworkState.getFrameworkID()), clock); assertFalse(taskInfo.getContainer().isInitialized()); assertTrue(taskInfo.getExecutor().getCommand().isInitialized()); assertEquals(2, taskInfo.getCommand().getUrisCount()); assertTrue(taskInfo.getCommand().getUris(0).getValue().contains(address)); }