Code Monkey home page Code Monkey logo

Comments (15)

nosan avatar nosan commented on May 18, 2024

You can add cassandra.embedded.system-properties[user.timezone]=Asia/Seoul to your application.properties

from embedded-cassandra-spring-boot-starter.

nosan avatar nosan commented on May 18, 2024

Or you can do:

@Bean
public CassandraBuilderConfigurator timezoneConfigurator(){
     return builder -> builder.addSystemProperty("user.timezone","Asia/Seoul");
}

from embedded-cassandra-spring-boot-starter.

jakim9913 avatar jakim9913 commented on May 18, 2024

Thanks for the reply
However, the code does not work and I get an error.

I don't have CassandraBuilderConfigurator.
image

What is CassandraBuilderConfigurator?

I used public class CassandraConfig extends AbstractReactiveCassandraConfiguration {}

I tried converting the local time as follows, but it doesn't work

@Bean
    public CassandraCustomConversions customConversions() {
        List<Converter<?, ?>> converters = new ArrayList<>();
        Set<Converter<?, ?>> converters2 = new HashSet<>();
        converters.add(new MyCustomConverter());

        return new CassandraCustomConversions(converters);
    }
    @ReadingConverter
    public class MyCustomConverter implements Converter<Instant, LocalDateTime> {
        @Override public LocalDateTime convert(Instant instant) { // 여기에서 필요한 변경사항을 적용하면 됩니다.
           // return LocalDateTime.ofInstant(instant, ZoneOffset.of("+09:00"));
            return ZonedDateTime.now(ZoneId.of("Asia/Seoul")).toLocalDateTime();

        }
    }

It's a web application, so it shouldn't affect time settings in other parts.

Isn't there a better way?

thank you

from embedded-cassandra-spring-boot-starter.

nosan avatar nosan commented on May 18, 2024

What version do you use? (Cassandra spring boot starter)

Have tried application properties?

from embedded-cassandra-spring-boot-starter.

jakim9913 avatar jakim9913 commented on May 18, 2024

I am using embedded Cassandra 3.11.7 with spring boot.

 <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-cassandra</artifactId>
            <version>2.2.2.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>com.github.nosan</groupId>
            <artifactId>embedded-cassandra-spring-boot-starter</artifactId>
            <version>2.0.5</version>

I have application propertise.

#Update Property File
#Tue Jan 19 09:46:34 KST 2021
cassandra.password=cassandra
cassandra.username=cassandra
cassandra.keyspace=manage
cassandra.ip=127.0.0.1
cassandra.port=9042
cassandra.jvm.xms=2g
cassandra.jvm.xmx=4g

from embedded-cassandra-spring-boot-starter.

nosan avatar nosan commented on May 18, 2024

Now it is clear :)

application.properties:

com.github.nosan.embedded.cassandra.system-properties[user.timezone]=Asia/Seoul

or


@Bean
public CassandraFactoryCustomizer<EmbeddedCassandraFactory> timezoneCustomizer(){
    return cassandraFactory -> cassandraFactory.getSystemProperties().put("user.timezone","Asia/Seoul");
}

from embedded-cassandra-spring-boot-starter.

jakim9913 avatar jakim9913 commented on May 18, 2024

thank for the reply.

However, it does not apply.

Here's what's applied:

  1. cassandra propertise
    cassandra.timezone=Asia/Seoul
  2. cassandra config
    @Value("${cassandra.timezone}") private String timezone;
  3. timezoneCustomizer method add
    @Bean public CassandraFactoryCustomizer<EmbeddedCassandraFactory> timezoneCustomizer(){ return cassandraFactory -> cassandraFactory.getSystemProperties().put("cassandra.timezone", timezone); }
  4. inser data - create time check

current time : 2022-04-19 17:20:35
DB insert time : 2022-04-19 08:15:35

There is still a 9 hour difference.

from embedded-cassandra-spring-boot-starter.

nosan avatar nosan commented on May 18, 2024

Why cassandra.timezone? Where did you get this?

from embedded-cassandra-spring-boot-starter.

jakim9913 avatar jakim9913 commented on May 18, 2024

I have cassadra.config

cassandra.username=
cassandra.keyspace=manage
cassandra.ip=127.0.0.1
cassandra.port=9042
cassandra.jvm.xms=2g
cassandra.jvm.xmx=4g```

from embedded-cassandra-spring-boot-starter.

nosan avatar nosan commented on May 18, 2024
@Value("${cassandra.timezone}") private String timezone;

    @Bean
    public CassandraFactoryCustomizer<EmbeddedCassandraFactory> timezoneCustomizer() {
        return cassandraFactory -> cassandraFactory.getSystemProperties().put("user.timezone", timezone);
    }

from embedded-cassandra-spring-boot-starter.

jakim9913 avatar jakim9913 commented on May 18, 2024

The insert time and the current time are still different.

Is it forced to change to utc timezone when inserted in cassandra?

from embedded-cassandra-spring-boot-starter.

nosan avatar nosan commented on May 18, 2024

user.timezone Java system property explicitly set a default time zone for Apache Cassandra.
How actually Cassandra treats this property I don't know, it is better to ask Cassandra's team.

from embedded-cassandra-spring-boot-starter.

nosan avatar nosan commented on May 18, 2024

I believe your question is not related to Embedded Cassandra. Looks like you have a general issue with how to work date-time values in Apache Cassandra.

from embedded-cassandra-spring-boot-starter.

jakim9913 avatar jakim9913 commented on May 18, 2024

thank you for your reply

If you know the Apache Cassandra official contact github address or Q&A site address, please share.

from embedded-cassandra-spring-boot-starter.

nosan avatar nosan commented on May 18, 2024

https://cassandra.apache.org/_/community.html

from embedded-cassandra-spring-boot-starter.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.