예제 #1
0
파일: Util.java 프로젝트: neojsy/myapp
  public static String getDateStr() {
    // String year = Util.Int2Str(time.get(time.YEAR));
    // String month = Util.Int2Str(time.get(time.MONTH) + 1);
    // String day = Util.Int2Str(time.get(time.DAY_OF_MONTH));

    GregorianCalendar time = new GregorianCalendar();

    String t;

    int day = time.get(time.DAY_OF_WEEK);
    String conversionDay = null;
    switch (day) {
      case 1:
        conversionDay = "Sun";
        break;

      case 2:
        conversionDay = "Mon";
        break;

      case 3:
        conversionDay = "Tue";
        break;

      case 4:
        conversionDay = "Wed";
        break;

      case 5:
        conversionDay = "Thu";
        break;

      case 6:
        conversionDay = "Fri";
        break;

      case 7:
        conversionDay = "Sat";
    }

    t =
        Util.Int2Str(time.get(time.YEAR))
            + "."
            + String.format(String.format("%02d", time.get(time.MONTH) + 1))
            + "."
            + String.format("%02d", time.get(time.DAY_OF_MONTH))
            + " "
            + conversionDay;

    return t;
  }
예제 #2
0
파일: Util.java 프로젝트: neojsy/myapp
  public static String getTimeStr() {
    // String hour = Util.Int2Str(time.get(time.HOUR));
    // String min = Util.Int2Str(time.get(time.MINUTE));

    GregorianCalendar time = new GregorianCalendar();

    String t;

    String hour = String.format("%02d", time.get(time.HOUR));
    if (hour.equals("00")) hour = "12";

    String apm;
    if (time.get(time.AM_PM) == time.AM) apm = "AM";
    else apm = "PM";

    t = hour + ":" + String.format("%02d", time.get(time.MINUTE));

    return t;
  }