`

Java String.format()的对于int,long

阅读更多

今天用String.format(format, args)方法,

format: "this num %l is long",args是一个long数

但运行有错,抛java.util.UnknownFormatConversionException,查了一下才知道,

原来%d是包括了int,long,byte等等类型了,

format:"this num %d is long"就行了。

详情可参考:http://blueram.iteye.com/blog/441683

分享到:
评论

相关推荐

    javascript.string.format:java的String.format()的Javascript实现;

    java 的 String.format() 的 Javascript 实现,增加了支持格式化百分比和后缀-SI,如 120M、30K。 将 Formatter.format() 移植到 javascript 的基本开始。 目前依赖 .toLocaleString() 进行命名日期格式。 请参阅...

    DateUtils.java 日期处理相关工具类

    * 文件名:DateUtils.java 日期处理相关工具类 * 版本信息:V1.0 * 日期:2013-03-11 * Copyright BDVCD Corporation 2013 * 版权所有 http://www.bdvcd.com */ public class DateUtils { /**定义常量**/ ...

    chatRoom 聊天室

    private static final long serialVersionUID = 3484437496861281646L; private JTextArea jta; // 多行文本域 private JLabel label; // 文本标签 private JTextField jtf; // 单行文本框 private JButton jb;...

    java常用工具类的使用

    调用DateFormat对象的format方法可以把Date对象转换成为指定格式的String类型数据。比如: Date today=new Date(); DateFormat df=DateFormat.getDateInstance(DateFormat.FULL,Locale.CHINA); String result=df....

    java sring mvc 及页面提交传参

    String formattedDate = dateFormat.format(date); model.addAttribute("serverTime", formattedDate ); return "home"; } @RequestMapping(value = "/Two", method = RequestMethod.GET) public ...

    java时间格式大全(算法源码)

    String dateString = formatter.format(currentTime); return dateString; } /** * 将长时间格式字符串转换为时间 yyyy-MM-dd HH:mm:ss * * @param strDate * @return */ public static Date strToDateLong...

    java 时区转换工具包

    1. 获取时区时间 public static ZonedDateTime getNow(int offset) 2. 解析指定时间 ...6. 时区格式转化 public static String formatTimeZoneToZone(String utcStr,String format,String zoneId) 7. 转化为实践戳

    java时间处理工具类--CalendarUtil(java源码)

    public static void main(String args[]) { System.out.println("First day of week is : " + new SimpleDateFormat("yyyy-MM-dd") .format(getFirstDateByWeek(new Date()))); System.out.println...

    ym_java-YOYOPlayer-src

    mport java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util....

    Android相机调用

    String name = DateFormat.format("yyyyMMdd_hhmmss",Calendar.getInstance(Locale.CHINA)) + ".jpg"; Toast.makeText(this, name, Toast.LENGTH_LONG).show(); Bundle bundle = data.getExtras(); ...

    java时间处理工具类--DateUtils

    * @(#)DateUtil.java * * * @author kidd * @version 1.00 2007/8/8 */ import java.util.*; import java.text.*; import java.sql.Timestamp; public class DateUtils { /** * 时间范围:年 */ ...

    JAVA时间处理类

    public static boolean isValidDate (String dateStr, String format) { try { getFormatter(format).parse(dateStr); return true; } catch (Exception e) { return false; } } /** * タイムの有効性...

    日期操作类 java

    public static final String LONG_DATE_FORMAT = "yyyy-MM-dd"; // 格式:月-日 public static final String SHORT_DATE_FORMAT = "MM-dd"; // 格式:小时:分钟:秒 public static final String LONG_TIME_...

    VS2010做的C#图片缩放实例

    ImageFormat sourceFormat = imageSource.RawFormat; int iSourceWidth = imageSource.Width; int iSourceHeight = imageSource.Height; decimal decTargetWidth = iSourceWidth*decTimes; decTargetWidth = Math....

    jsp探针 ver0.1

    space = Long.parseLong(results[i]); return space; } catch (NumberFormatException ex) { continue; } } return space; } catch (java.io.IOException e) { return -1; } } public long getObjectDisk() { ...

    Excel POI读取封装(文件+示范代码)

    if (classzz == Long.class) obj = Long.valueOf(src); if (classzz == Date.class) { if (src.contains(":")) { src = src.subSequence(0, src.indexOf(":")).toString(); } obj = java.sql.Date.valueOf...

    freemarker语法完整版

    sequence 序列,对应java 里的list 、数组等非键值对的集合 hash 键值对的集合 namespace 对一个ftl 文件的引用, 利用这个名字可以访问到该ftl 文件的资源 B 指令 if, else, elseif 语法 Java代码 ...

    java 数据库 课程设计 图书馆管理信息系统

    java 数据库 重点是实现了预约 违章等功能 public static int checkIt(String name, String password,String purview)// 验证用户名 密码 { interFace s = new interFace(); String temp = "select * from user...

    wzy17419.rar

    public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { View view ; ViewHolder viewHolder ; if ...

    servlet2.4doc

    The default behavior of this method is to call addDateHeader(String name, long date) on the wrapped response object. addDateHeader(String, long) - Method in interface javax.servlet....

Global site tag (gtag.js) - Google Analytics