Method to write a date

@param pValue
the value to write
@param pPattern
the Date pattern
@param pUseBcd
write date as BCD (binary coded decimal)
438157
public void setNextDate(final Date pValue, final String pPattern, final boolean pUseBcd) {
		// create date formatter
		SimpleDateFormat sdf = new SimpleDateFormat(pPattern);
		String value = sdf.format(pValue);

		if (pUseBcd) {
			setNextHexaString(value, value.length() * 4);
		} else {
			setNextString(value, value.length() * 8);
		}
	}
15693
public void toBinDate(TimeZone tz, byte[] bytes, Date value) throws PSQLException {
    long millis = value.getTime();

    if (tz == null) {
      tz = getDefaultTz();
    }
    // It "getOffset" is UNTESTED
    // See org.postgresql.jdbc.AbstractJdbc2Statement.setDate(int, java.sql.Date,
    // java.util.Calendar)
    // The problem is we typically do not know for sure what is the exact required date/timestamp
    // type
    // Thus pgjdbc sticks to text transfer.
    millis += tz.getOffset(millis);

    long secs = toPgSecs(millis / 1000);
    ByteConverter.int4(bytes, 0, (int) (secs / 86400));
  }
964611
public static void printDate(PrintWriter pw, String value) {
	long millis = System.currentTimeMillis();
	pw.write(FORMAT.format(new Date(millis)) + " " + value + "\n");
	pw.flush();
    }
154825
private void writeDecimalcolumn(DecimalColumnVector col, int cIdx,
                                  int rowNumber, ParseWriter dout) {
    HiveDecimalWritable[] oneColumn = col.vector;
    if(col.isRepeating) {
      HiveDecimal hd = oneColumn[0].getHiveDecimal();
      for (int rowIndex = 0; rowIndex < rowNumber; rowIndex++)
        dout.addNumCol(cIdx, hd.unscaledValue().longValue(),-hd.scale());
    } else  if(col.noNulls) {
      for (int rowIndex = 0; rowIndex < rowNumber; rowIndex++) {
        HiveDecimal hd = oneColumn[rowIndex].getHiveDecimal();
        dout.addNumCol(cIdx, hd.unscaledValue().longValue(),-hd.scale());
      }
    } else {
      boolean [] isNull = col.isNull;
      for (int rowIndex = 0; rowIndex < rowNumber; rowIndex++) {
        if (isNull[rowIndex])
          dout.addInvalidCol(cIdx);
        else {
          HiveDecimal hd = oneColumn[rowIndex].getHiveDecimal();
          dout.addNumCol(cIdx, hd.unscaledValue().longValue(), -hd.scale());
        }
      }
    }
  }
651325
public void writeBinary(final PacketOutputStream pos) throws IOException {
    if (fractionalSeconds) {
      pos.write((byte) 12);//length
      pos.write((byte) 0);
      pos.writeInt(0);
      pos.write((byte) time.getHour());
      pos.write((byte) time.getMinute());
      pos.write((byte) time.getSecond());
      pos.writeInt(time.getNano() / 1000);
    } else {
      pos.write((byte) 8);//length
      pos.write((byte) 0);
      pos.writeInt(0);
      pos.write((byte) time.getHour());
      pos.write((byte) time.getMinute());
      pos.write((byte) time.getSecond());
    }
  }
661494
public void writeBinary(final PacketOutputStream pos) throws IOException {
    Calendar calendar = Calendar.getInstance(timeZone);
    calendar.setTime(time);
    calendar.set(Calendar.DAY_OF_MONTH, 1);
    if (fractionalSeconds) {
      pos.write((byte) 12);
      pos.write((byte) 0);
      pos.writeInt(0);
      pos.write((byte) calendar.get(Calendar.HOUR_OF_DAY));
      pos.write((byte) calendar.get(Calendar.MINUTE));
      pos.write((byte) calendar.get(Calendar.SECOND));
      pos.writeInt(calendar.get(Calendar.MILLISECOND) * 1000);
    } else {
      pos.write((byte) 8);//length
      pos.write((byte) 0);
      pos.writeInt(0);
      pos.write((byte) calendar.get(Calendar.HOUR_OF_DAY));
      pos.write((byte) calendar.get(Calendar.MINUTE));
      pos.write((byte) calendar.get(Calendar.SECOND));
    }
  }
1116610
private static void writeZonePropsByDOW(Writer writer, boolean isDst, String tzname, int fromOffset, int toOffset,
            int month, int weekInMonth, int dayOfWeek, long startTime, long untilTime) throws IOException {
        beginZoneProps(writer, isDst, tzname, fromOffset, toOffset, startTime);

        beginRRULE(writer, month);
        writer.write(ICAL_BYDAY);
        writer.write(EQUALS_SIGN);
        writer.write(Integer.toString(weekInMonth));    // -4, -3, -2, -1, 1, 2, 3, 4
        writer.write(ICAL_DOW_NAMES[dayOfWeek - 1]);    // SU, MO, TU...

        if (untilTime != MAX_TIME) {
            appendUNTIL(writer, getDateTimeString(untilTime + fromOffset));
        }
        writer.write(NEWLINE);

        endZoneProps(writer, isDst);
    }
265161
public void formatWriter(String text, Object bindObj, String dateFormat,
			Writer writer) throws IOException, FormatException
	{
		writer.write(format(text,bindObj,dateFormat));
	}
817604
@SuppressWarnings("checkstyle:magicnumber")
	private void writeDBFDate(Date date) throws IOException {
		final SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); //$NON-NLS-1$
		writeDBFString(format.format(date), 8, (byte) ' ');
	}
730077
@Override
  public final Date fromString(final Map<String, Object> pAddParam,
    final String pStrVal) throws Exception {
    if (pStrVal == null || "".equals(pStrVal)) {
      return null;
    }
    return this.dateTimeSecNoTzFormatIso8601.parse(pStrVal);
  }
1200141
private void writeDoublecolumn(DoubleColumnVector vec, int colId, int rowNumber, ParseWriter dout) {
    double[] oneColumn = vec.vector;
    byte t = _setup.getColumnTypes()[colId];
    switch(t) {
      case Vec.T_CAT:
        if(_toStringMaps.get(colId) == null)
          _toStringMaps.put(colId,new HashMap<Number, byte[]>());
        HashMap<Number,byte[]> map = _toStringMaps.get(colId);
        BufferedString bs = new BufferedString();
        if(vec.isRepeating) {
          bs.set(StringUtils.toBytes(oneColumn[0]));
          for (int i = 0; i < rowNumber; ++i)
            dout.addStrCol(colId, bs);
        } else  if (vec.noNulls) {
          for (int i = 0; i < rowNumber; i++) {
            double d = oneColumn[i];
            if(map.get(d) == null) // TODO probably more effficient if moved to the data output
              map.put(d, StringUtils.toBytes(d));
            dout.addStrCol(colId, bs.set(map.get(d)));
          }
        } else {
          for (int i = 0; i < rowNumber; i++) {
            boolean [] isNull = vec.isNull;
            if (isNull[i])
              dout.addInvalidCol(colId);
            else {
              double d = oneColumn[i];
              if(map.get(d) == null)
                map.put(d,StringUtils.toBytes(d));
              dout.addStrCol(colId, bs.set(map.get(d)));
            }
          }
        }
        break;
      default:
        if(vec.isRepeating) {
          for (int i = 0; i < rowNumber; ++i)
            dout.addNumCol(colId, oneColumn[0]);
        } else  if (vec.noNulls) {
          for (int rowIndex = 0; rowIndex < rowNumber; rowIndex++)
            dout.addNumCol(colId, oneColumn[rowIndex]);
        } else {
          boolean [] isNull = vec.isNull;
          for (int rowIndex = 0; rowIndex < rowNumber; rowIndex++) {
            if (isNull[rowIndex]) dout.addInvalidCol(colId);
            else dout.addNumCol(colId, oneColumn[rowIndex]);
          }
        }
        break;
    }
  }
633376
public final void makePaymentMatchingReversed(
    final Map<String, Object> pReqVars, final String pPayId,
      final BankStatementLine pBsl, final DateFormat pDateFormat,
        final String pLangDef) throws Exception {
    EBankEntryResultType resultRecordType = null;
    EBankEntryResultAction resultAction = null;
    String resultDescription = null;
    Long resultRecordId = null;
    if (pBsl.getItsAmount().compareTo(BigDecimal.ZERO) > 0) {
      PaymentFrom pay = getSrvOrm().retrieveEntityById(pReqVars,
        PaymentFrom.class, Long.parseLong(pPayId));
      if (!pay.getHasMadeAccEntries() || pBsl.getItsAmount().abs()
        .compareTo(pay.getItsTotal()) != 0
          || pay.getSubaccCashType() != 2002 || !pBsl.getItsOwner()
            .getBankAccount().getItsId().equals(pay.getSubaccCashId())) {
        throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
          "record_is_not_matching");
      }
      resultRecordType = EBankEntryResultType.PAYMENTFROM;
      if (EBankEntryStatus.VOIDED.equals(pBsl.getItsStatus())
        && pay.getReversedId() == null) {
        resultAction = EBankEntryResultAction.CREATE;
        PaymentFrom reversed = pay;
        pay = new PaymentFrom();
        pay.setAccCash(reversed.getAccCash());
        pay.setSubaccCash(reversed.getSubaccCash());
        pay.setSubaccCashId(reversed.getSubaccCashId());
        pay.setSubaccCashType(2002);
        pay.setSalesInvoice(reversed.getSalesInvoice());
        pay.setForeignTotal(reversed.getForeignTotal().negate());
        pay.setDescription(makeDescrForCreated(pBsl, pDateFormat, pLangDef)
          + " " + getSrvI18n().getMsg("reversed_n", pLangDef) + reversed
            .getIdDatabaseBirth() + "-" + reversed.getItsId());
        makeDocReversed(pReqVars, pay, reversed, pLangDef);
      } else {
        resultAction = EBankEntryResultAction.MATCH;
      }
      resultRecordId = pay.getItsId();
      resultDescription = makeBslResDescr(resultAction, pDateFormat, pay,
        pay.getItsDate(), pLangDef);
    } else {
      PaymentTo pay = getSrvOrm().retrieveEntityById(pReqVars,
        PaymentTo.class, Long.parseLong(pPayId));
      if (!pay.getHasMadeAccEntries() || pBsl.getItsAmount().abs()
        .compareTo(pay.getItsTotal()) != 0
          || pay.getSubaccCashType() != 2002 || !pBsl.getItsOwner()
            .getBankAccount().getItsId().equals(pay.getSubaccCashId())) {
        throw new ExceptionWithCode(ExceptionWithCode.WRONG_PARAMETER,
          "record_is_not_matching");
      }
      resultRecordType = EBankEntryResultType.PAYMENTTO;
      if (EBankEntryStatus.VOIDED.equals(pBsl.getItsStatus())
        && pay.getReversedId() == null) {
        resultAction = EBankEntryResultAction.CREATE;
        PaymentTo reversed = pay;
        pay = new PaymentTo();
        pay.setAccCash(reversed.getAccCash());
        pay.setSubaccCash(reversed.getSubaccCash());
        pay.setSubaccCashId(reversed.getSubaccCashId());
        pay.setSubaccCashType(2002);
        pay.setPurchaseInvoice(reversed.getPurchaseInvoice());
        pay.setForeignTotal(reversed.getForeignTotal().negate());
        pay.setDescription(makeDescrForCreated(pBsl, pDateFormat, pLangDef)
          + " " + getSrvI18n().getMsg("reversed_n", pLangDef) + reversed
            .getIdDatabaseBirth() + "-" + reversed.getItsId());
        makeDocReversed(pReqVars, pay, reversed, pLangDef);
      } else {
        resultAction = EBankEntryResultAction.MATCH;
      }
      resultRecordId = pay.getItsId();
      resultDescription = makeBslResDescr(resultAction, pDateFormat, pay,
        pay.getItsDate(), pLangDef);
    }
    pBsl.setResultAction(resultAction);
    pBsl.setResultRecordType(resultRecordType);
    pBsl.setResultRecordId(resultRecordId);
    pBsl.setResultDescription(resultDescription);
    getSrvOrm().updateEntity(pReqVars, pBsl);
  }
353439
protected void writeDate(Date date, CharBuf buffer) {
        SimpleDateFormat formatter = new SimpleDateFormat(dateFormat, dateLocale);
        formatter.setTimeZone(timezone);
        buffer.addQuoted(formatter.format(date));
    }
1227364
@Override public void writeLongHex(long v) {
    writeHexByte(buf, pos + 0, (byte) ((v >>> 56L) & 0xff));
    writeHexByte(buf, pos + 2, (byte) ((v >>> 48L) & 0xff));
    writeHexByte(buf, pos + 4, (byte) ((v >>> 40L) & 0xff));
    writeHexByte(buf, pos + 6, (byte) ((v >>> 32L) & 0xff));
    writeHexByte(buf, pos + 8, (byte) ((v >>> 24L) & 0xff));
    writeHexByte(buf, pos + 10, (byte) ((v >>> 16L) & 0xff));
    writeHexByte(buf, pos + 12, (byte) ((v >>> 8L) & 0xff));
    writeHexByte(buf, pos + 14, (byte) (v & 0xff));
    pos += 16;
  }
539255
public Object setObjectValue(StringToObjectConverter pConverter, Object pInner, String pAttribute, Object pValue)
            throws IllegalAccessException, InvocationTargetException {
        throw new IllegalArgumentException("TabularData cannot be written to");
    }
1103769
private function _writeDatemode()
	{
		$record    = 0x0022;         // Record identifier
		$length    = 0x0002;         // Bytes to follow

		$f1904     = (PHPExcel_Shared_Date::getExcelCalendar() == PHPExcel_Shared_Date::CALENDAR_MAC_1904) ?
			1 : 0;   // Flag for 1904 date system

		$header    = pack("vv", $record, $length);
		$data      = pack("v", $f1904);
		$this->_append($header . $data);
	}
380066
@Override
	public Date parse(String text, ParsePosition pos) {
		text = convertW3cTimeZoneToRfc822(text); 
		if (pattern == Pattern.AUTO) {
			return autoParse(text, pos);
		}
		return super.parse(text, pos);
	}