Skip to content

Optimization: Make java.time.format.DateTimeFormatter instances final members #2329

Description

@abomb4
  • Is this an issue (and hence not a question)?

This is an optimization request: making the DateTimeFormatter in the generated MapperImpl a static member may improve performance.
Currently MapStruct (v1.4.1.Final) will generate date mapping method like:

if ( entity.getTime() != null ) {
    dto.setTime( DateTimeFormatter.ofPattern( "yyyy-MM-dd HH:mm:ss" ).format( entity.getTime() ) );
}

If make DateTimeFormatter.ofPattern( "yyyy-MM-dd HH:mm:ss" ) a static final member may be better.
DateTimeFormatter is thread-safe (https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html#patterns).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions