Java Today getTodayDisplayString()

Here you can find the source of getTodayDisplayString()

Description

get Today Display String

License

Open Source License

Declaration

public static String getTodayDisplayString() 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

public class Main {
    public static String getTodayDisplayString() {
        Calendar c = Calendar.getInstance();
        StringBuffer sb = new StringBuffer();
        sb.append(c.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.LONG, Locale.getDefault()));
        sb.append(", ");
        sb.append(get4CharDate(c.getTime()));
        return sb.toString();
    }// ww w .  j  a va 2  s  . c o m

    public static String get4CharDate(Date d) {
        if (d == null)
            return "";
        StringBuffer sb = new StringBuffer();
        // generate four-digit representation of date
        // e.g. last day of year & number of days to date, ex. 276th day
        Calendar c = Calendar.getInstance();
        c.setTime(d);
        int yr = c.get(Calendar.YEAR) % 10; // get least sig digit of year
        int numDays = c.get(Calendar.DAY_OF_YEAR);
        sb.append(yr);
        sb.append(numDays);
        return sb.toString();
    }
}

Related

  1. getTodayDate()
  2. getTodayDate()
  3. getTodayDateAsString()
  4. getTodayDateInString()
  5. getTodayDbFormat()
  6. getTodayEnd()
  7. getTodayEnd()
  8. getToDayEndTime()
  9. getTodayFolder()