Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

javaÖÐСÊý±£Áô¼°Ê±¼äµÄһЩ²Ù×÷

import java.text.DecimalFormat
double a = 2.3659874;
//СÊý¸ñʽ»¯£¬ÒýºÅÖеÄ0.000±íʾ±£ÁôСÊýµãºóÈý루µÚËÄλËÄÉáÎåÈ룩
DecimalFormat df = new DecimalFormat("0.000");
String num = df.format(a);
System.out.println(num);
Êä³ö½á¹û¾ÍÊÇ 2.366
Java¼ÆËãʱ¼ä²î
±ÈÈ磺ÏÖÔÚÊÇ2004-03-26 13£º31£º40
       ¹ýÈ¥ÊÇ£º2004-01-02 11£º30£º24
ÎÒÏÖÔÚÒª»ñµÃÁ½¸öÈÕÆڲ²îµÄÐÎʽΪ£ºXXÌìXXСʱXX·ÖXXÃë
·½·¨Ò»£º
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try
{
    Date d1 = df.parse("2004-03-26 13:31:40");
    Date d2 = df.parse("2004-01-02 11:30:24");
    long diff = d1.getTime() - d2.getTime();
    long days = diff / (1000 * 60 * 60 * 24);
}
catch (Exception e)
{
}
·½·¨¶þ£º
   SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
   java.util.Date now = df.parse("2004-03-26 13:31:40");
   java.util.Date date=df.parse("2004-01-02 11:30:24");
   long l=now.getTime()-date.getTime();
   long day=l/(24*60*60*1000);
   long hour=(l/(60*60*1000)-day*24);
   long min=((l/(60*1000))-day*24*60-hour*60);
   long s=(l/1000-day*24*60*60-hour*60*60-min*60);
   System.out.println(""+day+"Ìì"+hour+"Сʱ"+min+"·Ö"+s+"Ãë");
·½·¨Èý£º
   SimpleDateFormat dfs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
   java.util.Date begin=dfs.parse("2004-01-02 11:30:24");
   java.util.Date end = dfs.parse("2004-03-26 13:31:40");
   long between=(end.getTime()-begin.getTime())/1000;//³ýÒÔ1000ÊÇΪÁËת»»³ÉÃë
   long day1=between/(24*3600);
   long hour1=between%(24*3600)/3600;
   long minute1=between%3600/60;
   long second1=between%60/60;
   System.out.println(""+day1+"Ìì"+hour1+"Сʱ"+minute1+"·Ö"+second1+"Ãë");
========================================


Ïà¹ØÎĵµ£º

base64µÄjavaʵÏÖ·½·¨

package cn.eshore.mismp.sms.ws.send;
public class Base64 {
/**
* ½«Ô­Ê¼Êý¾Ý±àÂëΪbase64±àÂë
*/
static public char[] encode(byte[] data) {
char[] out = new char[((data.length + 2) / 3) * 4];
for (int i = 0, index = 0; i < data.length; i += 3, index += 4) {
boolean quad = false ......

Éú³Émyeclipse×¢²áÂëµÄjava³ÌÐò´úÂë

   ½ñÍíÔÚ¹äCSDNµÄʱºò·¢ÏÖÁË£¬ÓÐÈËÓÃjavaдÁËÉú³Émyeclipse×¢²áÂëµÄ´úÂ룬ËùÒԾͳ­Â¼ÁËÏÂÀ´¡£ o(∩_∩)o ¹þ¹þ
   package gggg;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class MyEclipseGen {
private static final ......

javaÖÐfloat/double¸¡µãÊýµÄ¼ÆËãʧ¾«¶ÈÎÊÌâ


½ñÌìÔÚÊýÖµ¼ÆËãʱÅöµ½Ò»¸öÎÊÌâ.³ÌÐòÈçÏÂ:
  double a = (3.3-2.4)/0.1;
  System.out.println(a);
Äã¿ÉÄÜÈÏΪ½á¹ûºÜ¼òµ¥,²»¾ÍÊÇ9Âï,ÊÇÊÂʵÉÏ,½á¹ûΪ:8.999999998,ΪʲôÄØ?ÎÒ·­ÔÄÁËһЩ×ÊÁÏ,ÖÕÓÚÕÒ³öÁËÔ­Òò.
Ϊʲô¸¡µãÊý»á¶ªÊ§¾«¶È£¿  
Ê®½øÖÆÊýµÄ¶þ½øÖƱíʾ¿ÉÄܲ»¹»¾«È·
¸¡µãÊý»òÊÇË«¾«¶È¸¡µ ......

»ñÈ¡Îļþ×îºóÐÞ¸Äʱ¼ä£¨java£©

import java.text.Format;
import java.text.SimpleDateFormat;
File file = new File("a.txt");
long time = file.lastModified();
Date d = new Date(time);
Format simpleFormat = new SimpleDateFormat("E dd MMM yyyy hh:mm:ss a");
String dateString = simpleFormat.format(d);
System.err.println(file.getN ......

PermGen space Java heap space ÄÚ´æÒç³ö


1¡¢
PermGen spaceµÄÈ«³ÆÊÇPermanent Generation space,ÊÇÖ¸ÄÚ´æµÄÓÀ¾Ã±£´æÇøÓòOutOfMemoryError: PermGen space´Ó±íÃæÉÏ¿´¾ÍÊÇÄÚ´æÒæ³ö£¬½â¾ö·½·¨Ò²Ò»¶¨ÊǼӴóÄڴ档˵˵Ϊʲô»áÄÚ´æÒæ³ö£ºÕâÒ»²¿·ÖÓÃÓÚ´æ·ÅClassºÍMetaµÄÐÅÏ¢,ClassÔÚ±» LoadµÄʱºò±»·ÅÈëPermGen spaceÇøÓò£¬ËüºÍºÍ´æ·ÅInstanceµÄHeapÇøÓò²»Í¬,GC(Garba ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ