Refine search
protected XMLGregorianCalendar _gregorianFromDate(DeserializationContext ctxt, Date d) { if (d == null) { return null; } GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(d); TimeZone tz = ctxt.getTimeZone(); if (tz != null) { calendar.setTimeZone(tz); } return _dataTypeFactory.newXMLGregorianCalendar(calendar); } }
/** * Sets the modification time of this {@code ZipEntry}. * * @param value * the modification time as the number of milliseconds since Jan. * 1, 1970. */ public void setTime(long value) { GregorianCalendar cal = new GregorianCalendar(); cal.setTime(new Date(value)); int year = cal.get(Calendar.YEAR); if (year < 1980) { modDate = 0x21; time = 0; } else { modDate = cal.get(Calendar.DATE); modDate = (cal.get(Calendar.MONTH) + 1 << 5) | modDate; modDate = ((cal.get(Calendar.YEAR) - 1980) << 9) | modDate; time = cal.get(Calendar.SECOND) >> 1; time = (cal.get(Calendar.MINUTE) << 5) | time; time = (cal.get(Calendar.HOUR_OF_DAY) << 11) | time; } }
protected Date addSingleUnitQuantity(Date startDate, String singleUnitQuantity) { int spaceIndex = singleUnitQuantity.indexOf(" "); if (spaceIndex == -1 || singleUnitQuantity.length() < spaceIndex + 1) { throw new ActivitiIllegalArgumentException("invalid duedate format: " + singleUnitQuantity); } String quantityText = singleUnitQuantity.substring(0, spaceIndex); Integer quantity = new Integer(quantityText); String unitText = singleUnitQuantity.substring(spaceIndex + 1).trim().toLowerCase(); int unit = units.get(unitText); GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(startDate); calendar.add(unit, quantity); return calendar.getTime(); } }
protected XMLGregorianCalendar _gregorianFromDate(DeserializationContext ctxt, Date d) { if (d == null) { return null; } GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(d); TimeZone tz = ctxt.getTimeZone(); if (tz != null) { calendar.setTimeZone(tz); } return _dataTypeFactory.newXMLGregorianCalendar(calendar); } }
@Override public XMLGregorianCalendar deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { Date d = _parseDate(jp, ctxt); if (d == null) { return null; } GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(d); return _dataTypeFactory.newXMLGregorianCalendar(calendar); } }
private GregorianCalendar getNowUTC() { final GregorianCalendar now = new GregorianCalendar(); now.setTimeZone(TimeZone.getTimeZone("UTC")); now.setTime(new Date(clock.getTime())); return now; }
public void setTime(long value) { GregorianCalendar cal = new GregorianCalendar(); cal.setTime(new Date(value)); int year = cal.get(Calendar.YEAR); if (year < 1980) { modDate = 0x21; time = 0; } else { modDate = cal.get(Calendar.DATE); modDate = (cal.get(Calendar.MONTH) + 1 << 5) | modDate; modDate = ((cal.get(Calendar.YEAR) - 1980) << 9) | modDate; time = cal.get(Calendar.SECOND) >> 1; time = (cal.get(Calendar.MINUTE) << 5) | time; time = (cal.get(Calendar.HOUR_OF_DAY) << 11) | time; } }
public GregorianCalendar get(TimeZone tz, Date date) { if (calendar == null) { calendar = new GregorianCalendar(tz, Locale.US); calendar.setGregorianChange(new Date(Long.MIN_VALUE)); // never use Julian calendar } else { // At least on Java 6, calendar.getTimeZone is slow due to a bug, so we need lastlySetTimeZone. if (lastlySetTimeZone != tz) { // Deliberately `!=` instead of `!<...>.equals()` calendar.setTimeZone(tz); lastlySetTimeZone = tz; } } calendar.setTime(date); return calendar; }
/** * Maps {@code stringValue} to {@code GregorianCalendar}. * * @param stringValue source value as a {@code String} * @return mapped {@code stringValue} to {@code GregorianCalendar} * @see DateTimeFormatter#ISO_DATE_TIME * @deprecated use new time API, such as {@link ZonedDateTime} */ @SuppressWarnings({"UseOfObsoleteDateTimeApi", "DeprecatedIsStillUsed"}) @Deprecated public static GregorianCalendar toGregorianCalendar(String stringValue) { GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(toDate(stringValue)); return calendar; }
protected XMLGregorianCalendar _gregorianFromDate(DeserializationContext ctxt, Date d) { if (d == null) { return null; } GregorianCalendar calendar = new GregorianCalendar(); calendar.setTime(d); TimeZone tz = ctxt.getTimeZone(); if (tz != null) { calendar.setTimeZone(tz); } return _dataTypeFactory.newXMLGregorianCalendar(calendar); } }
/** * Sets the modification time of this {@code ZipEntry}. * * @param value * the modification time as the number of milliseconds since Jan. * 1, 1970. */ public void setTime(long value) { GregorianCalendar cal = new GregorianCalendar(); cal.setTime(new Date(value)); int year = cal.get(Calendar.YEAR); if (year < 1980) { modDate = 0x21; time = 0; } else { modDate = cal.get(Calendar.DATE); modDate = (cal.get(Calendar.MONTH) + 1 << 5) | modDate; modDate = ((cal.get(Calendar.YEAR) - 1980) << 9) | modDate; time = cal.get(Calendar.SECOND) >> 1; time = (cal.get(Calendar.MINUTE) << 5) | time; time = (cal.get(Calendar.HOUR_OF_DAY) << 11) | time; } }
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { reader.moveDown(); long timeInMillis = Long.parseLong(reader.getValue()); reader.moveUp(); final String timeZone; if (reader.hasMoreChildren()) { reader.moveDown(); timeZone = reader.getValue(); reader.moveUp(); } else { // backward compatibility to XStream 1.1.2 and below timeZone = TimeZone.getDefault().getID(); } GregorianCalendar result = new GregorianCalendar(); result.setTimeZone(TimeZone.getTimeZone(timeZone)); result.setTime(new Date(timeInMillis)); // calendar.setTimeInMillis() not available under JDK 1.3 return result; }
/** * Sets the gregorian change date of this calendar. */ public void setGregorianChange(Date date) { gregorianCutover = date.getTime(); GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT")); cal.setTime(date); changeYear = cal.get(YEAR); if (cal.get(ERA) == BC) { changeYear = 1 - changeYear; } julianSkew = ((changeYear - 2000) / 400) + julianError() - ((changeYear - 2000) / 100); int dayOfYear = cal.get(DAY_OF_YEAR); if (dayOfYear < julianSkew) { currentYearSkew = dayOfYear-1; lastYearSkew = julianSkew - dayOfYear + 1; } else { lastYearSkew = 0; currentYearSkew = julianSkew; } }
public void testNegativeYearCompliance() throws Exception { TimeKvpParser timeKvpParser = new TimeKvpParser("TIME"); GregorianCalendar cal = new GregorianCalendar(); cal.setTimeZone(TimeZone.getTimeZone("GMT")); // base assertion - 0001 is year 1 DateRange date = (DateRange) ((List) timeKvpParser.parse("01-06-01")).get(0); cal.setTime(date.getMinValue()); assertEquals(1, cal.get(Calendar.YEAR)); assertEquals(GregorianCalendar.AD, cal.get(Calendar.ERA)); date = (DateRange) ((List) timeKvpParser.parse("00-06-01")).get(0); cal.setTime(date.getMinValue()); // calendar calls it year 1, ISO spec means it's year 0 // but we're just parsing here... assertEquals(1, cal.get(Calendar.YEAR)); assertEquals(GregorianCalendar.BC, cal.get(Calendar.ERA)); // so, the next year should be 2 date = (DateRange) ((List) timeKvpParser.parse("-01-06-01")).get(0); cal.setTime(date.getMinValue()); assertEquals(2, cal.get(Calendar.YEAR)); assertEquals(GregorianCalendar.BC, cal.get(Calendar.ERA)); // now, big negative year compliance (see the spec, appendix D 2.2, pp 57-58) date = (DateRange) ((List) timeKvpParser.parse("-18000-06-01")).get(0); cal.setTime(date.getMinValue()); assertEquals(18001, cal.get(Calendar.YEAR)); assertEquals(GregorianCalendar.BC, cal.get(Calendar.ERA)); }
GregorianCalendar cal = new GregorianCalendar(); cal.setTime(date); return fromCalendarFields(cal);
GregorianCalendar cal = new GregorianCalendar(); cal.setTime(date); return fromCalendarFields(cal);
public String print(Date v) { XMLSerializer xs = XMLSerializer.getInstance(); QName type = xs.getSchemaType(); GregorianCalendar cal = new GregorianCalendar(0,0,0); cal.setTime(v); if ((type != null) && (WellKnownNamespace.XML_SCHEMA.equals(type.getNamespaceURI())) && DATE.equals(type.getLocalPart())) { return DatatypeConverterImpl._printDate(cal); } else { return DatatypeConverterImpl._printDateTime(cal); } } });
@Override public void updateProcessInstanceLockTime(String processInstanceId) { Date expirationTime = getClock().getCurrentTime(); int lockMillis = getAsyncExecutor().getAsyncJobLockTimeInMillis(); GregorianCalendar lockCal = new GregorianCalendar(); lockCal.setTime(expirationTime); lockCal.add(Calendar.MILLISECOND, lockMillis); Date lockDate = lockCal.getTime(); executionDataManager.updateProcessInstanceLockTime(processInstanceId, lockDate, expirationTime); }
GregorianCalendar cal = new GregorianCalendar(); cal.setTime(date); return fromCalendarFields(cal);
public ServiceDay(Graph graph, long time, CalendarService cs, String agencyId) { TimeZone timeZone = cs.getTimeZoneForAgencyId(agencyId); GregorianCalendar calendar = new GregorianCalendar(timeZone); calendar.setTime(new Date(time * 1000)); serviceDate = new ServiceDate(calendar); init(graph, cs, timeZone); }