小编Cod*_*s B的帖子

Android - API 级别 21 中的日期

你好,我对 Android 还是有点陌生​​,

目前我对本地日期(或我尝试过的任何其他日期格式)有一个大问题

LocalDate currentDate = LocalDate().now();
Run Code Online (Sandbox Code Playgroud)

此行产生以下错误:

Call requires API Level 26 (current min is 21)
Run Code Online (Sandbox Code Playgroud)

我完全理解这意味着什么,但我无法更改项目的 API 级别(因为我与我的老师签订了合同,我和一个合作伙伴将按照我们计划的方式完成我们的学校项目。 )

如何在 API 级别 21 中使用任何类型的日期?

摇篮:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.example.fragment"
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "0.5"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

        }
    }
    android {
        compileOptions {
            coreLibraryDesugaringEnabled true
        }
    }
}


dependencies {
    implementation fileTree(dir: 'libs', …
Run Code Online (Sandbox Code Playgroud)

api android date

1
推荐指数
1
解决办法
1163
查看次数

标签 统计

android ×1

api ×1

date ×1