导航:首页 > 汇率佣金 > 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如何获取当前汇率相关的资料

    热点内容
    义务教育学校融资 浏览:721
    ppp模式融资担保 浏览:157
    沈阳有外汇业务的工商银行 浏览:269
    申购理财产品的原始凭证 浏览:530
    美丽华集团市值 浏览:524
    贵金属公司待遇 浏览:9
    国际结算在国际融资中的作用 浏览:49
    首次公开发行股票不得超过 浏览:464
    博信股份2019年一季度 浏览:982
    华泰证券债券回购 浏览:788
    上升下跌速率外汇指标 浏览:442
    杠杆的机械效率与物重有关吗 浏览:504
    手机工行怎么换外汇 浏览:408
    中原证券风险权限 浏览:719
    前海股权交易中心胡继之 浏览:447
    恒天财富信托延期兑付 浏览:822
    人鬼交易所2云资源 浏览:903
    邮储银行可以境外汇款吗 浏览:682
    温岭易转金融服务包装有限公司 浏览:782
    2016年日本汇率走势 浏览:468