Search in sources :

Example 41 with SimpleTimeZone

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;
}
Also used : SimpleTimeZone(java.util.SimpleTimeZone) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 42 with SimpleTimeZone

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;
}
Also used : SimpleTimeZone(java.util.SimpleTimeZone) SimpleDateFormat(java.text.SimpleDateFormat)

Example 43 with SimpleTimeZone

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;
}
Also used : SimpleTimeZone(java.util.SimpleTimeZone) SimpleDateFormat(java.text.SimpleDateFormat)

Example 44 with SimpleTimeZone

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());
}
Also used : UtcOffset(ezvcard.util.UtcOffset) SimpleTimeZone(java.util.SimpleTimeZone) Test(org.junit.Test)

Example 45 with SimpleTimeZone

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());
    }
}
Also used : SimpleTimeZone(java.util.SimpleTimeZone) File(java.io.File) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Test(org.junit.Test)

Aggregations

SimpleTimeZone (java.util.SimpleTimeZone)163 TimeZone (java.util.TimeZone)53 SimpleDateFormat (java.text.SimpleDateFormat)47 GregorianCalendar (java.util.GregorianCalendar)43 Date (java.util.Date)38 Calendar (java.util.Calendar)19 Test (org.junit.Test)16 DateFormat (java.text.DateFormat)8 File (java.io.File)5 NativeTimeZoneTest.isNativeTimeZone (com.google.j2objc.util.NativeTimeZoneTest.isNativeTimeZone)4 IOException (java.io.IOException)4 BasicDBObject (com.mongodb.BasicDBObject)3 InvalidObjectException (java.io.InvalidObjectException)3 Timestamp (java.sql.Timestamp)3 ParsePosition (java.text.ParsePosition)3 COSString (org.apache.pdfbox.cos.COSString)3 Support_TimeZone (tests.support.Support_TimeZone)3 DBRef (com.mongodb.DBRef)2 MessageFormat (java.text.MessageFormat)2 ParseException (java.text.ParseException)2