Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/342.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在爪哇将基督教年转换为泰国年?_Java_Android - Fatal编程技术网

Java 如何在爪哇将基督教年转换为泰国年?

Java 如何在爪哇将基督教年转换为泰国年?,java,android,Java,Android,现在我从JSON中获得日期时间的值,如下面的“end\u datetime”:“2020-12-31 20:08:00” 但当我在Textview中获得值时,我想将年份从2020>2563转换为年份 对不起,我的英语不好。您可以在包中使用class-java.time.chrono 您可以使用以下示例作为参考- public class Test { public static void main(String[] args) { String date =

现在我从JSON中获得日期时间的值,如下面的
“end\u datetime”:“2020-12-31 20:08:00”

但当我在
Textview
中获得值时,我想将年份从2020>2563转换为年份

对不起,我的英语不好。

您可以在包中使用class-
java.time.chrono

您可以使用以下示例作为参考-

    public class Test {


    public static void main(String[] args) {

        String date = "2020-12-31 20:08:00";
        // Convert Thai Buddhist date to ISO date

        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-mm-dd HH:MM:ss");
        try {
            ThaiBuddhistDate thaiBuddhistNow = ThaiBuddhistDate.from(LocalDate.parse(date,formatter));
            System.out.println("Thai  Buddhist Current Date  from  ISO:  "
                    + thaiBuddhistNow);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}

我已经根据您的日期时间格式更新了答案,并将其转换为泰国年份。请检查一下,希望能对您有所帮助。