2011-10-22 02:07:18 +00:00
|
|
|
/* ====================================================================
|
|
|
|
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
|
contributor license agreements. See the NOTICE file distributed with
|
|
|
|
|
this work for additional information regarding copyright ownership.
|
|
|
|
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
|
|
|
|
(the "License"); you may not use this file except in compliance with
|
|
|
|
|
the License. You may obtain a copy of the License at
|
|
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
|
limitations under the License.
|
|
|
|
|
==================================================================== */
|
2011-10-21 23:45:01 +00:00
|
|
|
package org.apache.poi.hpsf;
|
|
|
|
|
|
2011-10-22 01:57:58 +00:00
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
|
2011-10-21 23:45:01 +00:00
|
|
|
import org.apache.poi.util.LittleEndian;
|
2017-05-02 23:24:50 +00:00
|
|
|
import org.apache.poi.util.LittleEndianByteArrayInputStream;
|
|
|
|
|
import org.apache.poi.util.LittleEndianConsts;
|
2011-10-21 23:45:01 +00:00
|
|
|
|
2017-05-02 23:24:50 +00:00
|
|
|
class Filetime {
|
|
|
|
|
private static final int SIZE = LittleEndian.INT_SIZE * 2;
|
2011-10-21 23:45:01 +00:00
|
|
|
|
2011-10-22 01:57:58 +00:00
|
|
|
private int _dwHighDateTime;
|
|
|
|
|
private int _dwLowDateTime;
|
2017-05-02 23:24:50 +00:00
|
|
|
|
|
|
|
|
Filetime() {}
|
2011-10-21 23:45:01 +00:00
|
|
|
|
2017-05-02 23:24:50 +00:00
|
|
|
Filetime( int low, int high ) {
|
2011-10-22 01:57:58 +00:00
|
|
|
_dwLowDateTime = low;
|
|
|
|
|
_dwHighDateTime = high;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-02 23:24:50 +00:00
|
|
|
|
|
|
|
|
void read( LittleEndianByteArrayInputStream lei ) {
|
|
|
|
|
_dwLowDateTime = lei.readInt();
|
|
|
|
|
_dwHighDateTime = lei.readInt();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
long getHigh() {
|
2011-10-22 01:57:58 +00:00
|
|
|
return _dwHighDateTime;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-02 23:24:50 +00:00
|
|
|
long getLow() {
|
2011-10-22 01:57:58 +00:00
|
|
|
return _dwLowDateTime;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-02 23:24:50 +00:00
|
|
|
byte[] toByteArray() {
|
2011-10-22 01:57:58 +00:00
|
|
|
byte[] result = new byte[SIZE];
|
2017-05-02 23:24:50 +00:00
|
|
|
LittleEndian.putInt( result, 0 * LittleEndianConsts.INT_SIZE, _dwLowDateTime );
|
2011-10-22 01:57:58 +00:00
|
|
|
LittleEndian
|
2017-05-02 23:24:50 +00:00
|
|
|
.putInt( result, 1 * LittleEndianConsts.INT_SIZE, _dwHighDateTime );
|
2011-10-22 01:57:58 +00:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-02 23:24:50 +00:00
|
|
|
int write( OutputStream out ) throws IOException {
|
2011-10-22 01:57:58 +00:00
|
|
|
LittleEndian.putInt( _dwLowDateTime, out );
|
|
|
|
|
LittleEndian.putInt( _dwHighDateTime, out );
|
|
|
|
|
return SIZE;
|
2011-10-21 23:45:01 +00:00
|
|
|
}
|
|
|
|
|
}
|