久久久久久久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 ,則默認為 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 進行轉(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)前星期幾的值)
主站蜘蛛池模板: 亚洲一区二区三区四区五区中文 | 成人1区2区| 久久精品中文 | 91手机精品视频 | 91精品国产综合久久国产大片 | 欧美高清一级片 | 国产日韩精品在线 | 国产视频久久久 | 亚洲不卡一 | 久久久男人的天堂 | 亚洲视频一区 | 大吊一区二区 | 日本不卡免费新一二三区 | 久久精品欧美一区二区三区不卡 | 午夜爱爱毛片xxxx视频免费看 | 伊人久久在线 | 精品久久久久久久人人人人传媒 | 波多野结衣一区二区 | 亚洲精品av在线 | 国产激情网 | 中文字幕av一区二区三区 | 91网站在线观看视频 | 久久精品国产99国产精品 | 久久精品 | 看毛片的网站 | 午夜精品影院 | 国产精品爱久久久久久久 | 中文字幕在线观看 | 中文字幕在线二区 | 欧美成人免费在线 | 国产精品欧美大片 | 国产网站在线播放 | 欧美国产精品一区二区三区 | 久久久久久久久久久久久九 | 国产永久免费 | 精品熟人一区二区三区四区 | 国产一区二区久久 | 亚洲精品国产偷自在线观看 | 亚洲精品免费在线 | 欧美精品片 | 网站黄色av |