0

I am trying to use DateTimeFormatter to format date and time. Using below code

DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy/MM/dd"); dateFormat.format(LocalDateTime.now());

But it throws NoClassDefFoundError.

My gradle file having below configuration:

android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
    applicationId "com.example.myapplication"
    minSdkVersion 16
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    jackOptions {
        enabled true
    }
}

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

I am not getting what is wrong here.

K.Os
  • 5,123
  • 8
  • 40
  • 95
user2648519
  • 105
  • 2
  • 10

1 Answers1

1

Well, if you get that, it means the class doesn't exists.

Use RelativeDateTimeFormatter instead

Ionut J. Bejan
  • 734
  • 11
  • 28