use of java.util.SimpleTimeZone in project aliyun-oss-java-sdk by aliyun.
the class BucketOperationsSample method parseISO8601Date.
private static Date parseISO8601Date(String dateString) {
final String pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
SimpleDateFormat dateFormat = new SimpleDateFormat(pattern, Locale.US);
dateFormat.setTimeZone(new SimpleTimeZone(0, "GMT"));
Date date = null;
try {
date = dateFormat.parse(dateString);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}
use of java.util.SimpleTimeZone in project aliyun-oss-java-sdk by aliyun.
the class DateUtil method getRfc822DateFormat.
private static DateFormat getRfc822DateFormat() {
SimpleDateFormat rfc822DateFormat = new SimpleDateFormat(RFC822_DATE_FORMAT, Locale.US);
rfc822DateFormat.setTimeZone(new SimpleTimeZone(0, "GMT"));
return rfc822DateFormat;
}
use of java.util.SimpleTimeZone in project aliyun-oss-java-sdk by aliyun.
the class DateUtil method getIso8601DateFormat.
private static DateFormat getIso8601DateFormat() {
SimpleDateFormat df = new SimpleDateFormat(ISO8601_DATE_FORMAT, Locale.US);
df.setTimeZone(new SimpleTimeZone(0, "GMT"));
return df;
}
use of java.util.SimpleTimeZone in project ez-vcard by mangstadt.
the class TimezoneTest method constructors.
@Test
public void constructors() throws Exception {
Timezone property = new Timezone((String) null);
assertNull(property.getOffset());
assertNull(property.getText());
property = new Timezone(new UtcOffset(true, 1, 0));
assertEquals(new UtcOffset(true, 1, 0), property.getOffset());
assertNull(property.getText());
property = new Timezone(new SimpleTimeZone(1000 * 60 * 60, "ID"));
assertEquals(new UtcOffset(true, 1, 0), property.getOffset());
assertEquals("ID", property.getText());
property = new Timezone("text");
assertNull(property.getOffset());
assertEquals("text", property.getText());
property = new Timezone(new UtcOffset(true, 1, 0), "text");
assertEquals(new UtcOffset(true, 1, 0), property.getOffset());
assertEquals("text", property.getText());
}
use of java.util.SimpleTimeZone in project kafka by apache.
the class KeyValueSegmentsTest method shouldUpdateSegmentFileNameFromOldDateFormatToNewFormat.
@Test
public void shouldUpdateSegmentFileNameFromOldDateFormatToNewFormat() throws Exception {
// the old segment file's naming system maxes out at 1 minute granularity.
final long segmentInterval = 60_000L;
segments = new KeyValueSegments(storeName, METRICS_SCOPE, NUM_SEGMENTS * segmentInterval, segmentInterval);
final String storeDirectoryPath = stateDirectory.getAbsolutePath() + File.separator + storeName;
final File storeDirectory = new File(storeDirectoryPath);
// noinspection ResultOfMethodCallIgnored
storeDirectory.mkdirs();
final SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmm");
formatter.setTimeZone(new SimpleTimeZone(0, "UTC"));
for (int segmentId = 0; segmentId < NUM_SEGMENTS; ++segmentId) {
final File oldSegment = new File(storeDirectoryPath + File.separator + storeName + "-" + formatter.format(new Date(segmentId * segmentInterval)));
// noinspection ResultOfMethodCallIgnored
oldSegment.createNewFile();
}
segments.openExisting(context, -1L);
for (int segmentId = 0; segmentId < NUM_SEGMENTS; ++segmentId) {
final String segmentName = storeName + "." + (long) segmentId * segmentInterval;
final File newSegment = new File(storeDirectoryPath + File.separator + segmentName);
assertTrue(newSegment.exists());
}
}
Aggregations