Tag: String预览模式: 普通 | 列表
09-07
16

判断一个String中是否包含另一个String

老了,什么都想不起来了唉

String   str="I   am   a   student";  
  if(str.indexOf("am   a")   >   0)  
    return   true;  
  else  
    return   false;

查看更多...

Tags: 包含 String

分类:Java&Jsp | 固定链接 | 评论: 1 | 引用: 0 | 查看次数: 282
08-11
19

查找一个String变量中有多少的###page###

public class SplitString {
public static void main(String[] args) {

String context="sasdacont###page###extasdsaas###page###ddsaasdasd###page###saasdsasdadsadsa2131";

String[] subString = context.split("###page###");

int pageFlagNum = subString.length-1;

查看更多...

Tags: page String

分类:学习 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 494
08-06
20

format String to Date

jdk中已经不再推荐用Date.parse(String arg);这样的直接的转换,取而代之的是:
                     String birthdayS = request.getParameter("birthday");
            DateFormat f=new SimpleDateFormat("yyyy-MM-dd");
            try {
                birthday=f.parse(birthdayS);
            } catch (ParseException e) {
                e.printStackTrace();
                log.error("When format birthday from String to Date  is error");
            }

查看更多...

Tags: format String Date

分类:学习 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 569
The method setValue(String) in the type BaseInputTag is not applicable for the arguments (double)
这个错误一看就是转型错误
<html:text>表情只支持String 类型的变量,其他类型的变量需要先转换成String类型,如String.valueOf(double);

查看更多...

Tags: text String double

分类:Struts | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 2037
07-12
11

Date To String,String To Date

Locale locale = Locale.US;
   Date now=new Date();
   SimpleDateFormat f=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss",locale);
   String showTime=f.format(now);
  
  
  //String   s="2007-12-10 03:30:08 ";  
  //java.text.DateFormat   f1=new   java.text.SimpleDateFormat("yyyy-MM-dd hh:mm:ss",locale);  
  //java.util.Date   showTime=f.parse(s);

查看更多...

Tags: Date String 时间转换

分类:学习 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 1259