導航:首頁 > 匯率傭金 > java如何獲取當前匯率

java如何獲取當前匯率

發布時間:2022-04-07 02:19:14

⑴ 在JAVA中怎麼獲取當前時間的月份。並轉換成int型

在JAVA中獲取當前時間的月份並轉換成int型可以採用Calendar類提供的方法進行。

具體代碼如下:

Calendarcalendar=Calendar.getInstance();
//獲得當前時間的月份,月份從0開始所以結果要加1
intmonth=calendar.get(Calendar.MONTH)+1;

⑵ java:如何獲取當前活動的frame

不知道直接的方法
getFrames() 返回一個數組,包含由應用程序創建的所有 Frame。
getExtendedState() 獲取此 frame 的狀態。
用這兩個方法通過程序判斷吧

⑶ java 獲取當前日期,應該如何操作呢

package util;

import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
* 獲取系統時間
*

*/
public class DateUtil {
/* 日誌對象 */
// private static Logger logger = Logger.getLogger(SystemUtil.class);
/* 獲取年份 */
public static final int YEAR = 1;
/* 獲取年月 */
public static final int YEARMONTH = 2;
/* 獲取年月日 */
public static final int YEARMONTHDAY = 3;
/* 獲取年月日,小時 */
public static final int YMD_HOUR = 4;
/* 獲取年月日,小時,分鍾 */
public static final int YMD_HOURMINUTE = 5;
/* 獲取年月日,時分秒 */
public static final int FULL = 6;
/* 獲取年月日時分秒 格式:yyyyMMddHHmmss */
public static final int UTILTIME = 7;

/**
* 根據指定時間格式類型得到當前時間
*
* @param type
* 時間類型
* @return String 字元串時間
*/
public static synchronized String getCurrentTime(int type) {
String format = getFormat(type);
SimpleDateFormat timeformat = new SimpleDateFormat(format);
Date date = new Date();
return timeformat.format(date);
}

/**
* 返回當前系統時間的年月日
*
* @return
*/
public static synchronized String getCurrentTime() {
SimpleDateFormat timeformat = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
return timeformat.format(date);
}
/**
* 根據參數格式,格式化當前日期
* @param format
* @return
*/
public static synchronized String getDateString(String format) {
SimpleDateFormat timeformat = new SimpleDateFormat(format);
Date date = new Date();
return timeformat.format(date);
}

/**
* 根據指定時間格式類型,格式化時間格式
*
* @param type
* 時間格式類型
* @return
*/
private static String getFormat(int type) {
String format = "";
if (type == 1) {
format = "yyyy";
} else if (type == 2) {
format = "yyyy-MM";
} else if (type == 3) {
format = "yyyy-MM-dd";
} else if (type == 4) {
format = "yyyy-MM-dd HH";
} else if (type == 5) {
format = "yyyy-MM-dd HH:mm";
} else if (type == 6) {
format = "yyyy-MM-dd HH:mm:ss";
} else if (type == 7) {
format = "yyyyMMddHHmmss";
} else {
throw new RuntimeException("日期格式參數錯誤");
}
return format;
}

public static int getYear(String dateString) {
SimpleDateFormat dd = new SimpleDateFormat("yyyy-MM-dd");
Date date = null;
try {
date = dd.parse(dateString);
Calendar cal = Calendar.getInstance();
cal.setTime(date);
return cal.get(Calendar.YEAR);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public static int getMonth(String dateString) {
SimpleDateFormat dd = new SimpleDateFormat("yyyy-MM-dd");
Date date = null;
try {
date = dd.parse(dateString);
Calendar cal = Calendar.getInstance();
cal.setTime(date);
return cal.get(Calendar.MONTH)+1;
} catch (Exception e) {
throw new RuntimeException(e);
}
}

public static int getDay(String dateString) {
SimpleDateFormat dd = new SimpleDateFormat("yyyy-MM-dd");
Date date = null;
try {
date = dd.parse(dateString);
Calendar cal = Calendar.getInstance();
cal.setTime(date);
return cal.get(Calendar.DAY_OF_MONTH);
} catch (Exception e) {
throw new RuntimeException(e);
}
}

public static Date StringToDate(String dateStr, String formatStr) {
SimpleDateFormat dd = new SimpleDateFormat(formatStr);
Date date = null;
try {
date = dd.parse(dateStr);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}

/**
* 當前日期和參數日期距離的小時數 日期格式:yyyy-MM-dd HH:mm:ss
*
* @param date
* @return
*/
public static double getHours(String date) {
SimpleDateFormat timeformat = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
try {
Date d = new Date();
Date d1 = timeformat.parse(date);

long temp = d.getTime() - d1.getTime();
double f = temp / 3600000d;
BigDecimal b = new BigDecimal(f);
double f1 = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
return f1;
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}

public static void main(String a[]) {
try {
int aa = getYear("2012-01-08");
System.out.println(aa);
} catch (Exception e) {
e.printStackTrace();
}
}
}

⑷ 如何用Java獲取實時匯率

1.SE80 創建代理類
2.LPCONFIG 創建邏輯埠
3.寫程序
如果根據URL創建代理類的時候出現SPRX084的錯誤,請參考Notes:1046046、976964

⑸ java如何獲取當前時間 年月日 時分秒

java如何獲取當前時間以及格式化需要用到兩個類,如下圖:

「拓展資料——java」:

Java是一種廣泛使用的計算機編程語言,擁有跨平台、面向對象、泛型編程的特性,廣泛應用於企業級Web應用開發和移動應用開發。

Java編程語言的風格十分接近C++語言。繼承了C++語言面向對象技術的核心,舍棄了容易引起錯誤的指針,以引用取代;移除了C++中的運算符重載和多重繼承特性,用介面取代;增加垃圾回收器功能。

Java編程語言是個簡單、面向對象、分布式、解釋性、健壯、安全與系統無關、可移植、高性能、多線程和動態的語言。

    ⑹ 如何在java方法中獲得當前方法的名稱

    在java方法中獲得當前方法的名稱方法:

    一、獲得當前類名:

    Java代碼

    ⑺ JAVA中如何獲取到新加坡幣的格式

    java中有時區處理,你說的貨幣格式還沒聽過,就像多語言系統一樣,應該需要自己轉換單位。

    ⑻ java怎樣獲得系統當前的年份

    public static String getSysYear() {

    Calendar date = Calendar.getInstance();

    String year = String.valueOf(date.get(Calendar.YEAR));

    return year;

    }

    (8)java如何獲取當前匯率擴展閱讀:

    獲取當前系統時間和日期並格式化輸出:

    import java.util.Date;

    import java.text.SimpleDateFormat;

    public class NowString {

    public static void main(String[] args) {

    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//設置日期格式

    System.out.println(df.format(new Date()));// new Date()為獲取當前系統時間

    }

    }

    ⑼ 用java 怎麼得到實時匯率

    如果有webservices介面,直接調用就能拿到數據。

    ⑽ java 中如何獲取當前卡片

    自己記錄,沒有直接的方法。
    請參考

    閱讀全文

    與java如何獲取當前匯率相關的資料

    熱點內容
    外匯的交易時間 瀏覽:836
    中信銀行外幣交易價 瀏覽:172
    炫舞交易所粉雲怎麼買 瀏覽:187
    農行第一次買理財必須去銀行評估 瀏覽:375
    財通證券同花順下載 瀏覽:576
    信託公司產品運營 瀏覽:614
    信達證券融資賬號 瀏覽:305
    貸款有效咨詢 瀏覽:157
    國富光啟股東 瀏覽:339
    系統錄入貸款 瀏覽:524
    齊心集團蘇州分公司 瀏覽:532
    崑山貸款計算器 瀏覽:754
    紅豆股份什麼時候復牌 瀏覽:507
    國有控股上市公司數量 瀏覽:650
    美股持倉怎麼收費 瀏覽:174
    開一個證券賬戶傭金多少 瀏覽:379
    景區融資方案設計 瀏覽:130
    公寓租賃傭金 瀏覽:8
    興證資管年年鑫是基金還是理財 瀏覽:759
    永泰股份十大股| 瀏覽:133