Category: Java 開發 Q&A

[JAVA] How to send HTTP GET with params

Sorry, this entry is only available in 中文.

Tags : ,

[QA] singleton pattern in java

public Foo {
   private static final Foo INSTANCE = new Foo();
 
   public static Foo instance() {
      return INSTANCE;
   }
}
public enum Foo {
   INSTANCE;
}
Tags :

[QA] How to check java class built version

$ file ~/bin/classes/MyClass.class
 /home/abc/bin/classes/MyClass.class: compiled Java class data, version 50.0
  • 46 = Java 1.2
  • 47 = Java 1.3
  • 48 = Java 1.4
  • 49 = Java 5
  • 50 = Java 6
  • 51 = Java 7
Tags :

[QA] How to use regular expression to find year, month and day of date

String aDate = "date: 04-16-2013";
Pattern datePattern = Pattern.compile("date: (\\d{2})-(\\d{2})-(\\d{4})");
Matcher dateMatcher = datePattern.matcher(aDate);
if (dateMatcher.find()) {
   System.out.println("Month is: " + dateMatcher.group(1));
   System.out.println("Day is: " + dateMatcher.group(2));
   System.out.println("Year is: " + dateMatcher.group(3));
}
Tags : ,