Search in sources :

Example 16 with DateFormat

use of io.questdb.std.datetime.DateFormat in project questdb by bluestreak01.

the class TimestampFormatCompilerTest method testFormatBSTtoMSK.

@Test
public void testFormatBSTtoMSK() throws Exception {
    DateFormat fmt = get("dd-MM-yyyy HH:mm:ss Z");
    String targetTimezoneName = "MSK";
    long millis = fmt.parse("06-04-2017 01:09:30 BST", defaultLocale);
    millis += defaultLocale.getRules(targetTimezoneName, RESOLUTION_MICROS).getOffset(millis);
    sink.clear();
    fmt.format(millis, defaultLocale, targetTimezoneName, sink);
    TestUtils.assertEquals("06-04-2017 03:09:30 MSK", sink);
// assertThat("dd-MM-yyyy HH:mm:ss Z", "06-04-2017 03:09:30 MSK", "06-04-2017 01:09:30 BST");
}
Also used : DateFormat(io.questdb.std.datetime.DateFormat) Test(org.junit.Test)

Example 17 with DateFormat

use of io.questdb.std.datetime.DateFormat in project questdb by bluestreak01.

the class TimestampFormatCompilerTest method testNegativeYear.

@Test
public void testNegativeYear() throws Exception {
    assertThat("yyyy MMM dd", "-2010-09-01T00:00:00.000Z", "-2010 Sep 01");
    DateFormat fmt1 = compiler.compile("G yyyy MMM", true);
    DateFormat fmt2 = compiler.compile("yyyy MMM dd", true);
    long millis = fmt2.parse("-2010 Sep 01", defaultLocale);
    sink.clear();
    fmt1.format(millis, defaultLocale, "Z", sink);
    TestUtils.assertEquals("BC -2010 Sep", sink);
}
Also used : DateFormat(io.questdb.std.datetime.DateFormat) Test(org.junit.Test)

Example 18 with DateFormat

use of io.questdb.std.datetime.DateFormat in project questdb by bluestreak01.

the class DateFormatCompilerTest method testNegativeYear.

@Test
public void testNegativeYear() throws Exception {
    assertThat("yyyy MMM dd", "-2010-09-01T00:00:00.000Z", "-2010 Sep 01");
    DateFormat fmt1 = compiler.compile("G yyyy MMM", true);
    DateFormat fmt2 = compiler.compile("yyyy MMM dd", true);
    long millis = fmt2.parse("-2010 Sep 01", defaultLocale);
    sink.clear();
    fmt1.format(millis, defaultLocale, "Z", sink);
    TestUtils.assertEquals("BC -2010 Sep", sink);
}
Also used : DateFormat(io.questdb.std.datetime.DateFormat) Test(org.junit.Test)

Aggregations

DateFormat (io.questdb.std.datetime.DateFormat)18 Test (org.junit.Test)8 Record (io.questdb.cairo.sql.Record)4 RecordCursor (io.questdb.cairo.sql.RecordCursor)4 Function (io.questdb.cairo.sql.Function)2 StrFunction (io.questdb.griffin.engine.functions.StrFunction)2 UnaryFunction (io.questdb.griffin.engine.functions.UnaryFunction)2 StrConstant (io.questdb.griffin.engine.functions.constants.StrConstant)2 TimestampFormatCompiler (io.questdb.std.datetime.microtime.TimestampFormatCompiler)2 Path (io.questdb.std.str.Path)2 StringSink (io.questdb.std.str.StringSink)2 BindVariableServiceImpl (io.questdb.griffin.engine.functions.bind.BindVariableServiceImpl)1 FilesFacade (io.questdb.std.FilesFacade)1 FilesFacadeImpl (io.questdb.std.FilesFacadeImpl)1 DateLocale (io.questdb.std.datetime.DateLocale)1 File (java.io.File)1