久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

日歷構(gòu)造函數(shù) Java toString

Calendar Constructor Java toString(日歷構(gòu)造函數(shù) Java toString)
本文介紹了日歷構(gòu)造函數(shù) Java toString的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

限時送ChatGPT賬號..

我要做的是將日期傳遞到日歷中,以便它將格式化日期以供另一個構(gòu)造函數(shù)使用.這樣我以后可以使用日歷提供的功能來使用它.

What I'm trying to do is pass a date into the Calendar so that it will format the date ready for use with another constructor. So that i can make use of it later using the functions that calendar has provides.

public class Top {
public static void main(String[] args) {
    Something st = new Something(getCalendar(20,10,2012));       
    System.out.println(st.toString());       
    }

public static Calendar getCalendar(int day, int month, int year){
    Calendar cal = Calendar.getInstance();
    cal.set(Calendar.YEAR, year);
    cal.set(Calendar.MONTH, month);
    cal.set(Calendar.DAY_OF_MONTH, day);
    return cal;
    }
}

tostring 方法.

The tostring method.

public String toString(){
    String s = "nDate: " + DateD;
    return s;
}

日期:java.util.GregorianCalendar[time=?,areFieldsSet=false,areAllFieldsSet=true,lenient=true

Date: java.util.GregorianCalendar[time=?,areFieldsSet=false,areAllFieldsSet=true,lenient=true

而不是日期:20/10/2012

Rather than Date: 20/10/2012

推薦答案

假設(shè) DateDCalendar ,則默認(rèn)為 toString() 實現(xiàn).您需要調(diào)用 getTime() 來獲取 date.

Assuming DateD is Calendar , it is default toString() implementation. You need to call getTime() to get the date out of it.

來自 日歷#toString()

返回此日歷的字符串表示形式.此方法僅用于調(diào)試目的,返回字符串的格式可能因?qū)崿F(xiàn)而異.返回的字符串可能為空但不能為空.

Return a string representation of this calendar. This method is intended to be used only for debugging purposes, and the format of the returned string may vary between implementations. The returned string may be empty but may not be null.

您可以使用 SimpleDateFormat 進(jìn)行轉(zhuǎn)換它到 String

You can use SimpleDateFormat to convert it to String

這篇關(guān)于日歷構(gòu)造函數(shù) Java toString的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Parsing an ISO 8601 string local date-time as if in UTC(解析 ISO 8601 字符串本地日期時間,就像在 UTC 中一樣)
How to convert Gregorian string to Gregorian Calendar?(如何將公歷字符串轉(zhuǎn)換為公歷?)
Java: What/where are the maximum and minimum values of a GregorianCalendar?(Java:GregorianCalendar 的最大值和最小值是什么/在哪里?)
Calendar to Date conversion for dates before 15 Oct 1582. Gregorian to Julian calendar switch(1582 年 10 月 15 日之前日期的日歷到日期轉(zhuǎn)換.公歷到儒略歷切換)
java Calendar setFirstDayOfWeek not working(java日歷setFirstDayOfWeek不起作用)
Java: getting current Day of the Week value(Java:獲取當(dāng)前星期幾的值)
主站蜘蛛池模板: 操网站 | 国产欧美一区二区三区另类精品 | 蜜桃毛片 | 亚洲欧美日韩国产综合 | 亚洲欧美在线观看 | 午夜小电影| 91视频精选 | 老司机狠狠爱 | 91av在线视频观看 | 天天操天天干天天透 | 国产日韩精品在线 | 91免费观看视频 | 午夜视频在线观看视频 | 欧美国产精品一区二区三区 | 国产精品久久久久久一区二区三区 | 久久国品片 | 免费观看一级视频 | 毛片a级| 国产一区二 | 欧美精品一区三区 | 亚洲欧美在线观看视频 | 国产精品久久精品 | www.99热这里只有精品 | 永久www成人看片 | 精品欧美一区二区中文字幕视频 | 99久久日韩精品免费热麻豆美女 | 久久久影院 | 国产成人网 | 丝袜天堂| 最新中文字幕在线播放 | 亚洲女优在线播放 | 亚洲精品久久久蜜桃 | 特黄毛片| 久久亚洲一区 | 国产精品久久久久久二区 | 日韩国产欧美一区 | 国产乱码精品一区二区三区五月婷 | 91视频88av | 日日夜夜精品免费视频 | av在线电影网 | 一区二区三区欧美 |